Actually there is a difference, but not always (ah right).
In the use
construct, you never have to 'mention' the leading \
. Inline you never have to if the class is in the same namespace, or if you're using an import (imported with use ns
).
But sometimes you must:
namespace foo;
class bar extends \baz\Bar {
You're using an undefined/unknown/unimported class inline, so you have to mention its source.
Another example is with unnamespaced classes used in a namespace, inline:
namespace foo;
$dt = new \DateTime;
A best practice (generally) is to import ALL classes the current file needs. A use statement is very, very, very, very cheap, so don't hold back.
namespace foo;
use baz\Bar AS OtherBar;
use \DateTime;
class Bar extends OtherBar { // or something like that; in this case (same class name) it's tricky
function __construct() {
$dt = new DateTime;
edit 1
Also, don't forget to use fully namespaced class names when passing them as strings, even though you might be in the right namespace:
namespace foo;
$class = 'foo\bar';