PHP 脚本在 str_getcsv 上停止,没有错误
这里是新手,有一个令人沮丧但可能很简单的问题。我正在尝试编写一个脚本,该脚本将获取包含 2 列的 .csv 的最后一行。我只需要第二列中的值即可进行计算。我一直在尝试使用 str_getcsv 访问第二列,然后计算数学。该脚本在我的本地服务器上运行良好,但是当我上传到网络服务器时,脚本停止并且页面的其余部分不会加载。没有错误消息。这是我一直在使用的代码。它到达 hello1 echo 并停止。
$file = "test.csv";
//echo "hello";
$data = file($file);
$line = $data[count($data)-1];
echo "hello1";
$dump = str_getcsv($line);
echo "hello2";
$mynum = $dump[1]*1440;
echo $mynum;
Newbie here with a frustrating, but probably simple question. I am trying to write a script that will get the last line of a .csv with 2 columns. I only need the value in the second column to do a calculation. I have been trying to use str_getcsv to access the second column and then calculate the math. The script works fine on my local server but when I upload to the webserver the script stops and the rest of the page does not load. There are no error messages. Here is the code that I have been working with. It gets to the hello1 echo and stops.
$file = "test.csv";
//echo "hello";
$data = file($file);
$line = $data[count($data)-1];
echo "hello1";
$dump = str_getcsv($line);
echo "hello2";
$mynum = $dump[1]*1440;
echo $mynum;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的主机上安装的 PHP 版本是什么?
然后启用错误报告。
What PHP version is installed on your host?
Then enable error reporting.
在您的服务器上启用所有 php 错误。
确保
test.csv
可读。Enable all php error on your server.
Make sure that
test.csv
is readable.