Thursday 31 March 2016

Init class of a unnamed namespace inside other namespace

Hello,

How to init a class without namespace in another class with namespace:

<?php

class first_class {
   public function  __construct() {
   }
}

And:

<?php

namespace namespace1\namespace2;

class second_class {
         public function  __construct() {
         }

         public function test() {
                $object = first_class(); --> ERROR!!!!
                $object = \first_class(); --> OK
         }
}

Best regards!

No comments:

Post a Comment