Home  >  Article  >  Backend Development  >  【Thinkphp 5】 How to introduce extend extension file

【Thinkphp 5】 How to introduce extend extension file

丿诺言丿
丿诺言丿Original
2018-01-25 21:28:115886browse

extend/maile/cc.php file directory

cc file must be added with a namespace, as follows

cc.php file content is as follows:

namespace maile; //The namespace maile is the folder name class Cc { //Class name
public function ac(){ echo "chengjing";
}
}

In the controller Try it out

use maile\cc; //Reference the cc.php file in the maile folder

public function index()
{
$b=new Cc(); echo $b->ac(); // Output chengjing

}


The above is the detailed content of 【Thinkphp 5】 How to introduce extend extension file. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn