[仅在处理文件时带有爆炸语句的警告消息

问题描述 投票:1回答:1

仅当我使用explode语句处理文件时才会出现未定义的偏移量错误,它表示由explode语句创建的数组是未定义的,但是当我按照注释行中的代码处理正常的explode语句时则不是我可以在了解这一点上获得帮助吗?>

 <?php

 $file = "../hai/jobs.txt";
 if (file_exists($file))
 {
     $handle = fopen ($file,"r");
     if (!empty($file))
     {
         while (!feof($handle))
         {

             $curLine = fgets($handle); 
             if ($curLine != "")
             { 

                 $line = explode ("\t",$curLine);

                 echo $line[1];

                 //$a = "hai,how,are,you,going";
                 //$array = explode (",",$a);

                 //echo $array[1];
             }
         }
     }

     fclose($handle);
 }


 ?>
 </body>
 </html>

仅当我使用explode语句处理文件时才出现未定义的偏移量错误,它表示由explode语句创建的数组是未定义的,但是当我按照...]处理普通的explode语句时则未定义。 [

我相信问题仅仅是分隔符:您是否在文件中使用了\t(制表符)?如果使用与注释示例中相同的文本,则可能需要切换为逗号,
php offset isset
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.