首页 > 解决方案 > 如何读取和修复 * 未初始化 * 变量的控制台消息

问题描述

我正在开发一个读取 csv 文件并生成报告的应用程序。它工作正常。但是,当我在 Eclipse IDE 中运行我的应用程序时,我会在控制台上看到一些消息,我不确定这是否有问题。

我试图用它isset来修复uninitialized变量和函数,但它并没有解决我的问题。我的问题是:我应该担心这些信息吗?如果是,我该如何解决?如果我试图在 Unix 服务器上运行我的应用程序,我会出问题吗?我很难解释这些信息。

[Wed May  1 09:03:30 2019] PHP Stack trace:
[Wed May  1 09:03:30 2019] PHP   1. {main}() C:\Users\jj-localadmin\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\htdocs\ReportApplication4.3\index.php:0
[Wed May  1 09:03:30 2019] PHP   2. require_once() C:\Users\jj-localadmin\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\htdocs\ReportApplication4.3\index.php:14
[Wed May  1 09:03:30 2019] PHP   3. create_xlsx() C:\Users\jj-localadmin\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\htdocs\ReportApplication4.3\controller\upload.php:38
[Wed May  1 09:03:30 2019] PHP   4. require_once() C:\Users\jj-localadmin\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\htdocs\ReportApplication4.3\controller\upload.php:60
[Wed May  1 09:03:30 2019] PHP   5. createStatisticsReport($file = *uninitialized*) C:\Users\jj-localadmin\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\htdocs\ExcelReportApplication4.3\model\xlsxGenerator.php:26
[Wed May  1 09:03:30 2019] PHP   6. usort(*uninitialized*, *uninitialized*) C:\Users\jj-localadmin\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\htdocs\ReportApplication4.3\model\xlsxGenerator.php:187
[Wed May  1 09:03:30 2019] PHP   7. cmp($a = *uninitialized*, $b = *uninitialized*) C:\Users\jj-localadmin\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\htdocs\ReportApplication4.3\model\xlsxGenerator.php:187
[Wed May  1 09:03:30 2019] PHP Notice:  Undefined index: First Name in C:\Users\jj-localadmin\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\htdocs\ReportApplication4.3\model\readStatisticsFile.php on line 102
[Wed May  1 09:03:30 2019] PHP Stack trace:

在 5. 我正在检查变量是否为空,但它仍然给出错误。

错误:

[Wed May  1 09:03:30 2019] PHP   5. createStatisticsReport($file = *uninitialized*) C:\Users\jj-localadmin\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\htdocs\ExcelReportApplication4.3\model\xlsxGenerator.php:26

我的代码:

$fileName = 'data/uploadFile.csv'; // path for the csv file (registration and user statistics file are upload with the name)
if ($answer == "Statistics") {
    require_once 'readStatisticsFile.php';
    if (validateStatsFile($fileName) == 'true' && !empty($fileName))
                createStatisticsReport($fileName);```


标签: javascriptphpvariablesdebuggingconsole

解决方案


推荐阅读