PHP:意外 'StringLiteral'。预期的 ','

PHP: Unexpected 'StringLiteral'. Expected ','

我在 VS 代码 Unexpected 'StringLiteral'. Expected ',' 中收到此错误通知,代码如下 PHP。请帮我理解它有什么问题。我在以 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>,"
        . " service@pmm.com", "PO $dbh->Record['po_number'] needs Follow Up");
}

您需要转义 <a>

href 属性中的双引号
"<a href=\".......\">"

在引号内使用 ",例如:

$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>,"
        . " service@pmm.com", "PO $num needs Follow Up");
}