What is Smarty?
Why use it?
Use Cases and Work Flow
Syntax Comparison
Template Inheritance
Best Practices
Crash Course
You may use the Smarty logo according to the trademark notice.
For sponsorship, advertising, news or other inquiries, contact us at:
getRegisteredObject() — 获取已注册对象
array getRegisteredObject(string object_name);
该函数可以很方便地在自定义函数中获取一个注册对象。详情参见 对象。
Example 14.28. getRegisteredObject()
<?php function smarty_block_foo($params, $smarty) { if (isset($params['object'])) { // 获取已注册对象 $obj_ref = $smarty->getRegisteredObject($params['object']); // 现在可通过 $obj_ref 来操作对象 } } ?>