Add new comment

Another way to refer to a class is to use the "use" statement, after which the class name can be referred to without being fully qualified. In some cases, this may make the code a little more concise but still easy to understand, especially if there are multiple references to the class and its methods.

Following your example,

use Drupal\markus\Clothes\Pants; // Often placed at the top of the file.

$pants = new Pants();

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <code class> <ul type> <ol start type> <li> <dl> <dt> <dd><h3 id> <p>
  • Lines and paragraphs break automatically.