简单的php。。不工作…嗯,看起来很简单
请检查以下代码:简单的php。。不工作…嗯,看起来很简单,php,javascript,html,css,xhtml,Php,Javascript,Html,Css,Xhtml,请检查以下代码: <?php $d=2; echo "the sum of the number is"."<sub>($d+1)</sub>"; ?> 其输出: 数字之和为(2+1) 理想情况下,我需要输出为“数字之和为3”。 当我们不使用HTML标记时,它可以正常工作 如何修复此问题?将表达式移到引号外: <?php $d = 2; echo "the sum of the number is <sub>"
<?php
$d=2;
echo "the sum of the number is"."<sub>($d+1)</sub>";
?>
其输出:
数字之和为(2+1)
理想情况下,我需要输出为“数字之和为3”
。
当我们不使用HTML标记时,它可以正常工作
如何修复此问题?将表达式移到引号外:
<?php
$d = 2;
echo "the sum of the number is <sub>" . ($d+1) . "</sub>";
?>
试着把它写成
<?php $d=2; echo "the sum of the number is"."<sub>".($d+1)."</sub>"; ?>
引号为其提供了字符串表示形式,因此不允许执行加法