Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将HTML值分配给PHP变量-最佳实践?_Php_Html - Fatal编程技术网

将HTML值分配给PHP变量-最佳实践?

将HTML值分配给PHP变量-最佳实践?,php,html,Php,Html,现在,我以通常的方式将HTML分配给变量: $var = <<<END <blah>...</blah> END; $var=我试图通过使用诸如Smarty->之类的模板引擎尽可能避免这种情况。我尝试通过使用诸如Smarty->之类的模板引擎尽可能避免这种情况。如果您正在打印,您可以随时退出PHP并返回: <?php function print_header() { ?> <html> <

现在,我以通常的方式将HTML分配给变量:

$var = <<<END
<blah>...</blah>
END;

$var=我试图通过使用诸如Smarty->

之类的模板引擎尽可能避免这种情况。我尝试通过使用诸如Smarty->

之类的模板引擎尽可能避免这种情况。如果您正在打印,您可以随时退出PHP并返回:

<?php

function print_header() {
    ?>
    <html>
        <head>

        </head>
        <body>

    <?php
}

function print_footer() {
    ?>

        </body>
    </html>
    <?php
}

print_header();
print_footer();


如果您正在打印,您可以随时退出PHP并返回:

<?php

function print_header() {
    ?>
    <html>
        <head>

        </head>
        <body>

    <?php
}

function print_footer() {
    ?>

        </body>
    </html>
    <?php
}

print_header();
print_footer();


是的,模板引擎肯定是您通常想要处理HTML内容的方式。PHP本身已经是一个模板引擎。Smarty被高估了。是的,模板引擎肯定是您通常想要处理HTML内容的方式。PHP本身已经是一个模板引擎。Smarty被高估了。+1 PHP是一种模板语言。使用它,不要反抗它!当你说
$var='a load of HTML'
回显“一些带有不安全的$interpolation的html”你做错了+1 PHP是一种模板语言。使用它,不要反抗它!当你说
$var='a load of HTML'
回显“一些带有不安全的$interpolation的html”你做错了!