當我嘗試處理與命令行文件:錯誤時,命令行程序
cat texte.txt|php index.php
我得到這個奇怪的堆棧:
C:\wamp\www\Fraud Prevention>cat texte.txt|php index.php
PHP Notice: Undefined offset: 1 in C:\wamp\www\Fraud Prevention\index.php on li
ne 92
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 1 in C:\wamp\www\Fraud Prevention\index.php on line 92
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 2 in C:\wamp\www\Fraud Prevention\index.php on li
ne 94
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 2 in C:\wamp\www\Fraud Prevention\index.php on line 94
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 3 in C:\wamp\www\Fraud Prevention\index.php on li
ne 96
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 3 in C:\wamp\www\Fraud Prevention\index.php on line 96
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 4 in C:\wamp\www\Fraud Prevention\index.php on li
ne 98
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 4 in C:\wamp\www\Fraud Prevention\index.php on line 98
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 5 in C:\wamp\www\Fraud Prevention\index.php on li
ne 100
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 5 in C:\wamp\www\Fraud Prevention\index.php on line 10
0
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 6 in C:\wamp\www\Fraud Prevention\index.php on li
ne 102
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 6 in C:\wamp\www\Fraud Prevention\index.php on line 10
2
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 7 in C:\wamp\www\Fraud Prevention\index.php on li
ne 104
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 7 in C:\wamp\www\Fraud Prevention\index.php on line 10
4
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 1 in C:\wamp\www\Fraud Prevention\index.php on li
ne 92
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 1 in C:\wamp\www\Fraud Prevention\index.php on line 92
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 2 in C:\wamp\www\Fraud Prevention\index.php on li
ne 94
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 2 in C:\wamp\www\Fraud Prevention\index.php on line 94
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 3 in C:\wamp\www\Fraud Prevention\index.php on li
ne 96
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 3 in C:\wamp\www\Fraud Prevention\index.php on line 96
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 4 in C:\wamp\www\Fraud Prevention\index.php on li
ne 98
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 4 in C:\wamp\www\Fraud Prevention\index.php on line 98
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 5 in C:\wamp\www\Fraud Prevention\index.php on li
ne 100
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 5 in C:\wamp\www\Fraud Prevention\index.php on line 10
0
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 6 in C:\wamp\www\Fraud Prevention\index.php on li
ne 102
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 6 in C:\wamp\www\Fraud Prevention\index.php on line 10
2
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 7 in C:\wamp\www\Fraud Prevention\index.php on li
ne 104
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 7 in C:\wamp\www\Fraud Prevention\index.php on line 10
4
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 1 in C:\wamp\www\Fraud Prevention\index.php on li
ne 92
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 1 in C:\wamp\www\Fraud Prevention\index.php on line 92
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 2 in C:\wamp\www\Fraud Prevention\index.php on li
ne 94
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 2 in C:\wamp\www\Fraud Prevention\index.php on line 94
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 3 in C:\wamp\www\Fraud Prevention\index.php on li
ne 96
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 3 in C:\wamp\www\Fraud Prevention\index.php on line 96
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 4 in C:\wamp\www\Fraud Prevention\index.php on li
ne 98
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 4 in C:\wamp\www\Fraud Prevention\index.php on line 98
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 5 in C:\wamp\www\Fraud Prevention\index.php on li
ne 100
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 5 in C:\wamp\www\Fraud Prevention\index.php on line 10
0
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 6 in C:\wamp\www\Fraud Prevention\index.php on li
ne 102
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 6 in C:\wamp\www\Fraud Prevention\index.php on line 10
2
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
PHP Notice: Undefined offset: 7 in C:\wamp\www\Fraud Prevention\index.php on li
ne 104
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
Notice: Undefined offset: 7 in C:\wamp\www\Fraud Prevention\index.php on line 10
4
Call Stack:
0.0005 330608 1. {main}() C:\wamp\www\Fraud Prevention\index.php:0
編輯:
這裏是我的代碼在92和104之間:
$handle = fopen ("php://stdin","r");
$N = $title = fgets($handle, 1024);
while(!feof($handle))
{
if (!$order = fgets($handle)) continue;
$all_orders[] = explode(',', $order);
}
foreach ($all_orders as &$order){
$order["Order id"]=$order[0];
unset($order[0]);
$order["Deal id"]=$order[1];
unset($order[1]);
$order["Email address"]=$order[2];
unset($order[2]);
$order["Street address"]=$order[3];
unset($order[3]);
$order["City"]=$order[4];
unset($order[4]);
$order["State"]=$order[5];
unset($order[5]);
$order["Zip Code"]=$order[6];
unset($order[6]);
$order["Credit Card"]=$order[7];
unset($order[7]);
}
print_r($all_orders);
index.php,92-104行是什麼?您正在訪問不存在的數組項。 – Maerlyn 2012-01-08 16:11:33
我已經更新了我的代碼,從我的代碼的第92到第104行有一個片段,我不知道,但是它在小時前很好地工作,我沒有改變任何東西。 – Malloc 2012-01-08 16:17:25
@Malek你從'fgets()'調用中錯過了'trim()' - 我猜你已經有幾個空的項目了[你在幾個小時前](http:// stackoverflow。 com/questions/8777059)...'var_dump($ all_orders)'確認;-) – DaveRandom 2012-01-08 16:24:25