Why can't the _ autoload () method in php5 be used? use include_once (& quot ;... & quot;); in this way, if there are too many referenced classes, it is easy to forget to include a class, so I want to use the _ autoload () method, but when I write function _ autoload () {} indicates an error (a green line is drawn under _ autoload (), indicating that this method does not exist ). Why can't I use the _ autoload () method in php5?
Every time de_once ("...") is used on the page, if there are too many referenced classes, it is easy to forget to include a class, so I want to use the _ autoload () method,
However, when I write function _ autoload () {}, an error is returned (a green line is drawn under _ autoload (), indicating that this method does not exist ).
My IDE is jetBrains PhpStorm4.0.1 (I don't know if this is affected)
Don't understand, solve ....
------ Solution --------------------
Your code is correct. if the editor reports an error for _ autoload, it means that your php is not more than 5.0, or the editor's dictionary is too old.
------ Solution --------------------
Include_once ($ class. ". php"); // write the current path in this way.
------ Solution --------------------
Oh, that's right, phpstorm.
There is a green underline below, which does not prompt you for a problem, but prompts you that there is a problem with this word. when you move the mouse up, there will be two lines of selection operation, add the word to the dictionary.
Typo: Save "xxxx" to dic ....
It's a small bug in phpstorm.
------ Solution --------------------
Function _ autoload ($ class ){
Include_once ("path". $ class. ". php ");
}
Wrong. change to include_once ("path/". $ class. ". php ");