![Where are the public function files in the Yii framework located?](https://img.php.cn/upload/article/000/000/041/5e575e7f49789549.jpg)
We take the yii2-advanced version as an example:
![1582784191901862.png Where are the public function files in the Yii framework located?](https://img.php.cn/upload/image/456/744/973/1582784191901862.png)
##The above picture shows the basic directory structure of the yii2-advanced version, and. The /common directory is a public resource directory, and we can place the defined public methods in this directory.
In this directory, we can create a file at will, such as the "helps" directory. Considering that public methods may be divided into functional categories, we create a unified directory for management.
![1582784220604796.png Where are the public function files in the Yii framework located?](https://img.php.cn/upload/image/608/851/722/1582784220604796.png)
Two tool classes are created here.
(Recommended tutorial:
yii framework)
YII2 adopts PHP’s new feature namespace
Establishing public methods
<?php
namespace common\helps;
/*
* 自定义全局公共方法
*/
class tools{
public static function hello(){
echo 'hello world!';
}
}
?>
Copy after login
For more programming-related content, you can follow the
Introduction to Programming column on the php Chinese website!
The above is the detailed content of Where are the public function files in the Yii framework located?. For more information, please follow other related articles on the PHP Chinese website!