本文實(shí)例講述了Yii擴(kuò)展組件編寫(xiě)方法。分享給大家供大家參考。具體如下:
因?yàn)閅ii本身就引入了Prado的component-based 思想做為主要思想。因此,組件在yii中是很重要的。
組件一般放在components目錄里,其格式示例基本如下:
<?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
}
}
使用方法格式示例:
<?php
echo Utilities::testTool($param);
?>
實(shí)現(xiàn)的理由也很簡(jiǎn)單,由于所有的擴(kuò)展繼承了系統(tǒng)的基類(lèi),因此,在應(yīng)用中使用該方法時(shí),yii會(huì)導(dǎo)入注冊(cè)該類(lèi)方法。
希望本文所述對(duì)大家基于Yii框架的php程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選