Named rules
Add one for private
Add two is usually the system default, the system is predefined, that is, the so-called: "Magic Method" and "Magic constant"
The constant that PHP starts and ends with double underlines is "magic constant":
The current line number in the __line__ file.
The full path and file name of the __file__ file.
The directory where the __dir__ file resides. If used in the included file, returns the directory where the included files are located. It is equivalent to DirName (__file__). Unless it is a root directory, the name in the directory does not include the trailing slash
Note: The above is from the "PHP Chinese Manual, language Reference, constant-and magic constant".
From the later version of PHP5, the PHP class will be able to use the Magic method.
PHP rules to start with two underscore (__) methods are preserved as a magic method, it is recommended that the function name is best not to start without __, unless it is to reload the existing magic method.
The Magic Methods in PHP are: __construct, __destruct, __call, __callstatic,__get, __set, __isset, __unset, __sleep, __wakeup, __toString, __set_state, __clone, __autoload
__autoload
The __autoload function, which is called automatically when trying to use a class that has not yet been defined. By calling this function, the scripting engine has the last chance to load the required classes before PHP fails.
If you are defining a global auto-load class, you must register the processing class with the PHP standard library using the Spl_autoload_register () method:
<?php class loader { static function autoload_ Class ($class _name) { //look for the right $class_name class, and introduce, no then throw an exception } } /** * Setting Object Auto-loading * spl_autoload_register - register given function as __autoload () Implementation */ spl_autoload_register (Array (' Loader ', ' Autoload_class '); $a = new test ();//test does not use require on the instantiation, realizes the automatic loading, Many frameworks use this method to automatically load class ?>
Note: Exceptions thrown in the __autoload function cannot be caught by a catch statement block and cause a fatal error, so the function itself should be captured.
(Original post: http://blog.csdn.net/zlking02/article/details/6752256)
The meaning of a variable that starts with an underscore in PHP