0
PHP Notice:  Undefined index: parentid in /home/public_html/data/Dataset.php on line 319
PHP Notice:  Undefined index: destinations in /home/public_html/data/Dataset.php on line 330
PHP Notice:  Undefined index: radiogroup in /home/public_html/data/Dataset.php on line 340
PHP Notice:  Undefined index: radiogroup in /home/public_html/data/Dataset.php on line 340
PHP Notice:  Undefined index: radiogroup in /home/public_html/data/Dataset.php on line 340
PHP Notice:  Undefined index: radiogroup in /home/public_html/data/Dataset.php on line 340
PHP Notice:  Undefined index: name in /home/public_html/data/Dataset.php on line 220
PHP Notice:  Undefined index: fieldhelp in /home/public_html/data/Dataset.php on line 236

5.2からphp5.3にアップグレードした後、スクリプトが機能しません。ログに多くのPHP通知が表示されています。

319行目:if( $this->aFields["parentid"] ) {

340行目: if( $curField["radiogroup"] ) {

そのような行がたくさん含まれている別のファイルに問題があるのではないかと思います

 if( isset( $this->request_vars[$name]["id"] ) ) {

これを修正するにはどうすればよいですか?上から判断して簡単なら。

4

4 に答える 4

2

エラーではありません。配列$curFieldにインデックス「radiogroup」などの要素がないことを示しています。

最初に isset を使用して存在するかどうかを確認する必要があります。次に例を示します。

if(isset($curField['radiogroup']) and $curField['radiogroup']) {
于 2012-10-11T13:46:19.527 に答える
1

未定義のインデックスは、存在しない連想配列のキーにアクセスしようとしていることを意味します。これは古い構成に存在するはずですが、エラー報告レベルが原因で発生しませんでした。

変数が設定されているかどうかを最初にテストしてから使用するために、コードを変更する必要があります。

例えば:

フォームの出現箇所を変更:

if( $this->aFields["parentid"] ) {
   ...
}

if( isset($this->aFields["parentid"]) ) {
   ...
}
于 2012-10-11T13:49:55.377 に答える
1

PHP ドキュメント ( error_reporting ) から:

<?php
// Turn off all error reporting
error_reporting(0);
?>

その機能のその他の興味深いオプション:

<?php

// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);

// Report all PHP errors (see changelog)
error_reporting(E_ALL);

// Report all PHP errors
error_reporting(-1);

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);

?>
于 2012-10-11T13:50:53.470 に答える
0

コードからはわかりにくいですが、エラー報告レベルが変更され、通知が表示されるようになったと思います。ただし、変数が存在しない可能性がある場合は、次のようなものを使用する必要があります。

if( isset($this->aFields["parentid"]) ) {

あなたの場合、空を使用できます。これは、セットと値の両方をチェックし、0/false に等しくないためです (元の行と同じ)。

if( ! empty($this->aFields["parentid"]) ) {
于 2012-10-11T13:43:47.163 に答える