Include

xiaoxiao2021-03-06  53

Technical Note: Include_php is pretty much deprecated from smarty, you can acidplish the Same FunctionAlicity

Via a Custom Template Function. The only reason to use include_php is if you real Have a Need to quarantine the

PHP Function Away from The Plugin Directory Or Your Application Code. See The Componentized Template Example

For details.

INCLUDE_PHP TAGS Are Used to include a PHP Script in Your Template. If Security Is Enabled, THE PHP Script Must Be Located

In the $ trusted_dir path. The include_php tag must have the attribute "file", Which contains the path to the include PHP file,

Either relative to $ trusted_dir, or an absolute path.

INCLUDE_PHP IS A Nice WAY to Handle Componentized Templates, And Keep PHP Code Separate from The Template Files. Lets Say

You Have a Template That Shows Your Site Navigation, Which Is Pulled Dynamically from a database you can keyp Your PHP

Logic That Grabs Database Content in a Separate Directory, and incdude it at the top of the template. Now you can include this

Template Anywhere WITHOUT WORRYING IF The Database Information Was Assigned by The Application Before Hand.

By Default, PHP Files Are ONLY Included overce Even if Called Multiple Times in The Template. You CAN Specify That Should Be

INCLUDED EVERY TIME with the overce attribute. setting overce to false Will include the php script each time it is incriped in the PHP Script

Template.

You can optionally pass the assign attribute, Which Will Specify A Template Variable Name That The Output of Include_PHP WILL

Be assigned to instead of displayed.

The Smarty Object Is Available As $ this within The PHP Script That You Include.

Example 7.9. Function Include_php

转载请注明原文地址:https://www.9cbs.com/read-81914.html

New Post(0)