且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么PHP不替换字符串中的变量?

更新时间:2023-02-18 20:59:29

这是因为您需要使用双引号代替. 当用单引号引起来时,php不会将变量转换为它们的值

That is because you need to use double quote instead. php will not convert variables to their values when surrounded by single quotes

<?php
$someVariable = 0;
echo "SomeVariable is $someVariable";
?>