PHP 脚本在 str_getcsv 上停止,没有错误

发布于 2024-12-17 02:25:41 字数 414 浏览 4 评论 0原文

这里是新手,有一个令人沮丧但可能很简单的问题。我正在尝试编写一个脚本,该脚本将获取包含 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

苍暮颜 2024-12-24 02:25:41

http://php.net/manual/en/function.str -getcsv.php

(PHP 5 >= 5.3.0)

您的主机上安装的 PHP 版本是什么?

没有错误消息。

然后启用错误报告。

http://php.net/manual/en/function.str-getcsv.php

(PHP 5 >= 5.3.0)

What PHP version is installed on your host?

There are no error messages.

Then enable error reporting.

风吹过旳痕迹 2024-12-24 02:25:41
  • 在您的服务器上启用所有 php 错误。

  • 确保 test.csv 可读。

  • Enable all php error on your server.

  • Make sure that test.csv is readable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文