我不知道我在做什麼錯在這裏,但我得到解析錯誤: 「解析錯誤:語法錯誤,意外','在...「試圖使用回聲的逗號,而不是字符串連接
$msg= 'This is ', htmlentities($from, ENT_QUOTES, 'UTF-8'),' and ', htmlentities($to, ENT_QUOTES, 'UTF-8'),' dates statistic ';
echo $msg;
你能幫我嗎?由於速度較慢,我不想使用連接。
我不知道我在做什麼錯在這裏,但我得到解析錯誤: 「解析錯誤:語法錯誤,意外','在...「試圖使用回聲的逗號,而不是字符串連接
$msg= 'This is ', htmlentities($from, ENT_QUOTES, 'UTF-8'),' and ', htmlentities($to, ENT_QUOTES, 'UTF-8'),' dates statistic ';
echo $msg;
你能幫我嗎?由於速度較慢,我不想使用連接。
在$味精由.
將字符串之間,
:
$msg= 'This is ' . htmlentities($from, ENT_QUOTES, 'UTF-8') . ' and ' .
htmlentities($to, ENT_QUOTES, 'UTF-8') . ' dates statistic ';
,或者直接回應:
echo 'This is ', htmlentities($from, ENT_QUOTES, 'UTF-8'),' and ', htmlentities($to, ENT_QUOTES, 'UTF-8'),' dates statistic ';
Basicaly逗號分隔值參數。您正在嘗試將參數傳遞給變量但不回顯!
echo 'This is ',
htmlentities($from, ENT_QUOTES, 'UTF-8'),
' and ',
htmlentities($to, ENT_QUOTES, 'UTF-8'),
' dates statistic ';
回波接受用逗號separted多個值,變量分配沒有。
,將工作
echo 'This is ', htmlentities($from, ENT_QUOTES, 'UTF-8'),' and ', htmlentities($to, ENT_QUOTES, 'UTF-8'),' dates statistic ';
或
$msg= 'This is '. htmlentities($from, ENT_QUOTES, 'UTF-8') . ' and ' . htmlentities($to, ENT_QUOTES, 'UTF-8') . ' dates statistic ';
echo $msg;
非常感謝您提供這些信息!不知道。 – Christine
在字符串賦值您不能使用逗號,逗號只爲echo
命令本身的工作。所以,如果你想避免串聯,你上面提到你需要這樣做:
echo 'This is ', htmlentities($from, ENT_QUOTES, 'UTF-8'),
' and ', htmlentities($to, ENT_QUOTES, 'UTF-8'),' dates statistic ';
非常感謝您提供這些信息!不知道。 – Christine
echo 'This is ', htmlentities($from, ENT_QUOTES, 'UTF-8'),' and ', htmlentities($to, ENT_QUOTES, 'UTF-8'),' dates statistic ';
中的逗號只能echo
合作,而不是與變量賦值。
非常感謝您的信息!不知道。 – Christine