我在Unexpected 'StringLiteral'. Expected ','帶有以下 PHP 代碼的 VS 代碼中收到此錯誤通知。請幫助我理解其中有什么問題。我在以 Click to.. 開頭的行中看到此錯誤。
while ($dbh->next_record()) {
$tracker_info = json_decode($dbh->Record['tracker_info'], TRUE);
inform_sl_operations("PO$dbh->Record['po_number'] needs Follow Up. Due: $dbh->Record['alert'] \n"
. " Click to <a href="'search_results.php?po_number=$dbh->Record['po_number']'">view order</a>,"
. " [email protected]", "PO $dbh->Record['po_number'] needs Follow Up");
}
uj5u.com熱心網友回復:
使用"內引號,例如:
$string = "href="example.com"";
是錯誤的,需要轉義,例如:
$string = "href=\"example.com\"";
另一個可能的錯誤,不要這樣做:
$string = "$dbh->Record['po_number']";
存盤在變數中然后使用,例如:
$po_number = $dbh->Record['po_number'];
$string = " ... $po_number ... ";
嘗試類似:
while ($dbh->next_record()) {
$tracker_info = json_decode($dbh->Record['tracker_info'], TRUE);
$num = $dbh->Record['po_number'];
$alert = $dbh->Record['alert'];
inform_sl_operations("PO $num needs Follow Up. Due: $alert \n"
. " Click to <a href=\"search_results.php?po_number=$num\">view order</a>,"
. " [email protected]", "PO $num needs Follow Up");
}
uj5u.com熱心網友回復:
您需要轉義href屬性中的雙引號<a>
"<a href=\".......\">"
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/365821.html
