亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Small questions about the automatic loading of Dugu Jiujian class __autoload()
葫蘆娃平衡盤
葫蘆娃平衡盤 2017-08-09 00:06:19
0
2
1289

class class name{
function__autoload($ClassName){
$path=$ClassName.'.php';
if(file_exists($path)){//Judge whether the file exists
???????????????????????????????????????????????????????????????????????
, I checked it several times, but I couldn’t see the statement meaning $ClassName =test. So how could he import text.php?

葫蘆娃平衡盤
葫蘆娃平衡盤

reply all(2)
聽裝雪碧

That is, when you create a new test class name, the __autoload method will be executed, and the class name test after your new will be passed into this method as a parameter

聽裝雪碧

When you want to reference a non-existent class in this class, after writing the __autoload method, it will automatically determine whether the class file exists, and if it exists, it will be executed.

require_once($path) refers to the class file

You can add the following code to your file

echo (new Autoload1())->god();

echo (new Autoload1())->name;


and then test.php Write

class Test

{

public $name = 'I am the attribute name in the Test class file';

public function god(){

return 'I am the method god in the Test class file' ()';

}

}

You can see that this Test file is automatically introduced and the value can be successfully output


Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template