How the Class file is including in another file php using the namesapce and Use? -


i have class called errors in errors.php

namespace myclass;     class errors     {         private $_codes = array(             301 => array(                 "code"=> 301,                 "message"=> "user id not found",                 "type"=> "error"             )         );           public static function geterror($code)         {             return $this->_codes[$code];         } 

in myclass.php have

namespace myclass;  use myclass\errors;  require'vendor/autoload.php';  

inside myclass have afunction , checking errors

echo errors::geterror(301); 

it shows class myclass not found error

fatal error: class 'myclass\errors' not found in /var/www/myclass/myclass.php 

what have missed here?

you have include errors.php


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -