English 中文(简体)
聪明:如何将营地纳入模板?
原标题:Smarty: how to include php in template?
  • 时间:2011-07-08 13:52:16
  •  标签:
  • php
  • smarty

I ve Trial {include_php file="phpfile.php>} and {php} tags but both causes deprecated误差. 难道你不能在聪明地这样做吗? 我无法从中找到任何东西。

问题回答

我回避了这一问题。 创建名为block.php_code.php的原始文档,其功能如下:

function smarty_block_php_code($params, $content, &$smarty)
{
    if (is_null($content))
    {
        return;
    }
    if ( <?php  == substr($content,0,5) &&  ?>  == substr($content, -2))
        $content = substr($content,5,-2);
    ob_start();
    eval($content);
    return ob_get_clean();
}

在你的模板中,你可以写:

{php_code}{literal}<?php

    print "Hello, world!";

?>{/literal}{/php_code}

他们之所以被贬低,是因为他们允许不良做法。 聪明建议将这些文字纳入购买力平价逻辑,或创建plugin(简单易懂)。

{php} 标签偏离了智慧,不应使用。 而用购买力平价的文字或原始功能描述你的购买力平价逻辑。

{include_php} is deprecated from Smarty, use registered plugins to properly insulate presentation from the application code.

Source

If you include what you are trying to do in your phpfile.php, we can help you write a plugin function.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签