Name
registerClass() 鈥 娉ㄥ唽绫
璇存槑
void聽registerClass(string聽class_name,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽string聽class_impl);
鍦瀹夊叏璁剧疆璁稿彲涓嬶紝Smarty鍏佽浣犱娇鐢registerClass()
鏉ユ敞鍐岄潤鎬佺被鍒版ā鏉夸腑浣跨敤銆
Example聽14.36.聽娉ㄥ唽绫
<?php class Bar { $property = "hello world"; } $smarty = new Smarty(); $smarty->registerClass("Foo", "Bar"); ?>
{* 瀹夊叏璁剧疆璁稿彲涓嬶紝妯℃澘涓彲浠ヤ娇鐢ㄨ绫 *} {Bar::$property} {* Foo 灏嗚浆鎹㈡垚鐪熷疄鐨勭被 Bar *} {Foo::$property}
Example聽14.37.聽娉ㄥ唽甯﹀懡鍚嶇┖闂寸殑绫
<?php namespace my\php\application { class Bar { $property = "hello world"; } } $smarty = new Smarty(); $smarty->registerClass("Foo", "\my\php\application\Bar"); ?>
{* Foo灏嗚浆鎹㈡垚鐪熷疄鐨勭被 \my\php\application\Bar *} {Foo::$property}
鍙傝
registerObject()
,
鍜
瀹夊叏.