<table cellspacing="0" cellpadding="0" border="0" width="100%" summary="Header navigation table"><tbody><tr><th align="center" colspan="3">Smarty - the compiling PHPtemplate engine</th> </tr><tr><td valign="bottom" align="left" width="25%"><a accesskey="P" href="api.registerplugin.html">Prev</a></td> <td valign="bottom" align="center" width="50%">Chapter 13. Smarty Class Methods()</td> <td valign="bottom" align="right" width="25%"><a accesskey="N" href="api.register.resource.html">Next</a></td> </tr></tbody></table> # registerObject()[注册对象] Name registerObject() ― register an object for use in the templates 注册一个在模板中使用的对象 Description void registerObject(string object_name,object object,array allowed_methods_properties,boolean format,array block_methods); <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 提示 </caption> <tr><td><p>Note<br/> When you register/assign objects to templates, be sure that all properties and methods accessed from the template are for presentation purposes only. It is very easy to inject application logic through objects, and this leads to poor designs that are difficult to manage. See the Best Practices section of the Smarty website.</p> <p>当你为模板注册/分配对象时,请注意赋值给模板的所有属性和方法只能作为描述表现逻辑为目的。在模板中很容易注入应用逻辑,这将造成设计混乱从而难以管理。请参见Smarty网站中关于最佳实践章节。</p></td> </tr></table> See the objects section for more information. See also getRegisteredObject(), and unregisterObject(). 更多信息查看[对象](#)章节。 参见[getRegisteredObject()](#)和[unregisterObject()](#)。 <table cellspacing="0" cellpadding="0" border="0" width="100%" summary="Footer navigation table"><tbody><tr><td valign="top" align="left" width="33%"><a accesskey="P" href="api.registerplugin.html">Prev</a></td> <td valign="top" align="center" width="34%"><a accesskey="H" href="index.html">Home</a></td> <td valign="top" align="right" width="33%"><a accesskey="N" href="api.register.resource.html">Next</a></td> </tr><tr><td valign="top" align="left" width="33%">registerPlugin()<br/> 注册插件</td> <td valign="top" align="center" width="34%"><a accesskey="U" href="api.functions.html">Up</a></td> <td valign="top" align="right" width="33%">registerResource()<br/> 注册资源</td> </tr></tbody></table>