使用 codeigniter 的 php 中的 file_get_contents 错误?
我正在做本教程,但使用不同的 xml http://blog.insicdesigns.com/2009/03/parsing-xml-file-using-codeigniters-simplexml-library/,但我不断收到相同的错误: 遇到 PHP 错误 严重性:通知 消息:未定义的变量:myxml 文件名:controllers/welcome.php 行号:45
这是我的mi代码:我将xml文件放在目录C:\ Users \ beto \ Documents \ xml \ myxml.xml中,但我认为我错了你可以帮助我,或者告诉我如何修复它?
function _getXML($fname)
{
$filename = $fname.’.xml’;
$xmlfile=“C:\\Users\\beto\\Documents\\xml”.$filename;
**$xmlRaw = file_get_contents($xmlfile);**ERROR
$this->load->library(‘simplexml’);
$xmlData = $this->simplexml->xml_parse($xmlRaw);
foreach($xmlData[‘Emisor’] as $row)
{
$result .= ‘<tr>’;
$result .= ‘<td>’.$row[‘id’].’</td>’;
$result .= ‘<td>’.$row[‘name’].’</td>’;
$result .= ‘<td>’.$row[‘category’].’</td>’;
$result .= ‘<td>$ ‘.$row[‘price’].’</td>’;
$result .= ‘</tr>’;
}
return $result;
}
I am doing this tutorial but with a diferent xml http://blog.insicdesigns.com/2009/03/parsing-xml-file-using-codeigniters-simplexml-library/, but I keep getting the same error:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: myxml
Filename: controllers/welcome.php
Line Number: 45
this my mi code: I put the xml file in the directory C:\Users\beto\Documents\xml\myxml.xml, but I think I am wrong can you help me, or tell me how to fix it?
function _getXML($fname)
{
$filename = $fname.’.xml’;
$xmlfile=“C:\\Users\\beto\\Documents\\xml”.$filename;
**$xmlRaw = file_get_contents($xmlfile);**ERROR
$this->load->library(‘simplexml’);
$xmlData = $this->simplexml->xml_parse($xmlRaw);
foreach($xmlData[‘Emisor’] as $row)
{
$result .= ‘<tr>’;
$result .= ‘<td>’.$row[‘id’].’</td>’;
$result .= ‘<td>’.$row[‘name’].’</td>’;
$result .= ‘<td>’.$row[‘category’].’</td>’;
$result .= ‘<td>$ ‘.$row[‘price’].’</td>’;
$result .= ‘</tr>’;
}
return $result;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
缺少
\
,请替换为:a
\
is missing, replace like: