获取变量php错误
我正在尝试将 xml 文件加载到 php 以显示表格
// load SimpleXML
$d = $_GET['d'];
$books = new SimpleXMLElement('books.xml?cat=($d)', null, true);
echo <<<EOF
<table>
<tr>
<th>Title</th>
<th>Author</th>
<th>Publisher</th>
<th>Price at Amazon.com</th>
<th>ISBN</th>
</tr>
EOF;
foreach($books as $book) // loop through our books
{
echo <<<EOF
<tr>
<td>{$book->title}</td>
<td>{$book->author}</td>
<td>{$book->publisher}</td>
<td>\${$book->amazon_price}</td>
<td>{$book['isbn']}</td>
</tr>
EOF;
}
echo '</table>';
我无法让 Get 变量返回任何数据。希望你能帮助我。
i am trying to load an xml file to php in order to display a table
// load SimpleXML
$d = $_GET['d'];
$books = new SimpleXMLElement('books.xml?cat=($d)', null, true);
echo <<<EOF
<table>
<tr>
<th>Title</th>
<th>Author</th>
<th>Publisher</th>
<th>Price at Amazon.com</th>
<th>ISBN</th>
</tr>
EOF;
foreach($books as $book) // loop through our books
{
echo <<<EOF
<tr>
<td>{$book->title}</td>
<td>{$book->author}</td>
<td>{$book->publisher}</td>
<td>\${$book->amazon_price}</td>
<td>{$book['isbn']}</td>
</tr>
EOF;
}
echo '</table>';
i am unable to get the Get variable return any data.hope you can help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是单引号与双引号的问题。
更改
为
...并再次阅读此内容。适当地。
This is a single vs double quote issue.
Change
to
...and read this again. Properly.
至少
'books.xml?cat=($d)'
没有展开。您需要使用双引号。At the very least
'books.xml?cat=($d)'
is not expanded. You need to use double quotes.