This article describes the Yii extension component writing method with examples. Share it with everyone for your reference. The details are as follows:
Because Yii itself has introduced Prado’s component-based idea as the main idea. Therefore, components are very important in Yii.
Components are generally placed in the components directory, and their format examples are basically as follows:
<?php /** * some description about the <span style="color: rgb(34, 34, 34); font-family: Arial, sans-serif; font-size: 12.800000190734863px; line-height: 19px; ">components</span> */ class Utilities extends CController { public static function testTool($param) { // codes } }
Usage method format example:
<?php echo Utilities::testTool($param); ?>
The reason for the implementation is also very simple. Since all extensions inherit the base class of the system, when this method is used in the application, Yii will import and register the method of this class.
I hope this article will be helpful to everyone’s PHP programming based on the Yii framework.