gpt4 book ai didi

php - 无法访问 Heredoc 中的数组

转载 作者:行者123 更新时间:2023-12-01 22:47:46 26 4
gpt4 key购买 nike

为什么此代码在我尝试访问 $sector_value['sector_info']['purchase_order']; 的行上给出错误?但不是在第五行,我打印出变量 $sector_counter

//SECTOR
$email_body .= <<<SECTOR_DETAILS
<tr>
<td colspan="2">
Sector $sector_counter;
</td>
</tr>

<tr>
<td colspan="2">
Purchase order
</td>
</tr>
<tr>
<td colspan="2">
$sector_value['sector_info']['purchase_order'];
</td>
</tr>

<tr>
<td>
Proof
</td>
</tr>

SECTOR_DETAILS;

这是错误:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www2isco/public_html/test/bch/queries/submit_order.php on line 44

谢谢!

最佳答案

将变量括在 { .. } 中,它位于 the docs 中.

//SECTOR
$email_body .= <<<SECTOR_DETAILS
<tr>
<td colspan="2">
Sector $sector_counter;
</td>
</tr>

<tr>
<td colspan="2">
Purchase order
</td>
</tr>
<tr>
<td colspan="2">
{$sector_value['sector_info']['purchase_order']}
</td>
</tr>

<tr>
<td>
Proof
</td>
</tr>

SECTOR_DETAILS;

关于php - 无法访问 Heredoc 中的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13555254/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com