Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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
PHP HTML{$variable}_Php_Html_Variables - Fatal编程技术网

PHP HTML{$variable}

PHP HTML{$variable},php,html,variables,Php,Html,Variables,如何打印括号中的变量?例如,像ip板,我有以下代码: <?php $variable = "test"; ?> <div class="test">{$variable}</div> 我该怎么做?不是 echo$变量;?> 但是{$variable}!提前感谢:3你可以这样使用它 <?= $variable ?> 是的,你可以这样做 <?php $variable = "test"; ?> <div class="te

如何打印括号中的变量?例如,像ip板,我有以下代码:

<?php
$variable = "test";
?>
<div class="test">{$variable}</div>
我该怎么做?不是

echo$变量;?>


但是{$variable}!提前感谢:3

你可以这样使用它

<?= $variable ?>

是的,你可以这样做

<?php
    $variable = "test";
?>
<div class="test"><?= $variable; ?></div>
但如果你想使用上述方法,你必须使用刀片模板引擎


这叫做串联,它使用“.”将事物串在一起

<div class="test"><?php echo '{'.$variable.'}' ?></div>

使用php模板引擎。最适合你的是使用拉威尔和巴尔德,我知道。。但是我不想{$variable}你想显示一个变量而不回显它,哦。那么,什么不回响。。。。意思是?你的意思是你想打印{test}还是你想让{}导致数据被打印?这个问题比午夜的烂泥更清楚不。。。我不想{$variable}你必须使用blade,也许你可以从Laravel开始来实现这一点不。。。我不想{$variable}你在开玩笑吗?我不想用{$variable}打印变量值,不想用echo…你在开玩笑吗问题是。。。你在开玩笑吗@你在开玩笑吗?你说的是括号里的打印变量。抱歉,我试图帮助你回答一个措辞拙劣的问题。是的,或者创建你自己的模板系统