Tutorial :PHP 5.3 Namespaces and use


i am wondering why my namespaces are not resolved correctly ... i have

use \Doctrine\ORM;  ...   } catch (NoResultException $e) { // shld resolve to \Doctrine\ORM\NoResultException but fails  ...   } catch () {      // code always ends up here if NoResultException is thrown      // unless i fully qualify the class as\Doctrine\ORM\NoResultException  }  


use \Doctrine\ORM;  

This declare an alias named ORM that points to \Doctrine\ORM. It doesn't mean that all the class name you mention in your code will use this alias. You still have to specify that you want to use it like this :

catch (ORM\NoResultException) {  

ORM\NoResultException will point to \Doctrine\ORM\NoResultException

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »