Suppression Error @ Doesn't work

I happily used the error suppression operator in my PHP-dev setup. But recently, they have been notified so:

Note. Uninitialized line offset: 0 in C: \ websites \ xxx \ htdocs \ includes \ myscript.php on line 35

Line 35:

$ file_name = @ $ File ['file_name'];

I have display_errors on and error_reporting is 6143 (E_ALL).

Am I missing something? Should the error be suppressed?

Edit:

Tested in virgin script:

$ a = array ();
$ b = @ $ a ['f5'];

Error suppression. Therefore, I think that we are somehow changing the value of error_reporting. (Film at 11)

thanks for reference yr.

+5
source share
4 answers

, , .

Uninitialized string offset. :

# 1

$a = 0;
$b = $a['f5'];

$a - . PHP . '0' 1.

PHP , , PHP . :

$s= 'abcd';
print_r($s[1]);

b, . # 1 'f5' , . echo intval('f5'); , PHP 'f5' 0 .

? , # 2

# 2

$a = '';
$b = $a['f5'];

$a - . $b= $a[0]; - , . , PHP , , :

Notice: Uninitialized string offset: 0 in C:\websites\tcv3\wc2009\htdocs\aatest_array.php on line 3

.

+5

0, . ; "_".

, '@' - . , script - , . , , :

if (isset($File['file_name'])) {
  $file_name = $File['file_name'];
} else {
  // throw exception, return FALSE, print an error and exit, whatever
}
+1

, : PHP - vars. :

$a = 0;
$b = $a['f5'];

.

:

$a = '';
$b = $a['f5'];

:

Notice: Uninitialized string offset: 0 in C:\websites\tcv3\wc2009\htdocs\aatest_array.php on line 3

. $a array(), . , .

, PHP 5.2.2. - ?

.

0

No, the suppressor @avoids displaying warnings from function calls, not access variables and declarations. Noticetells you that you are accessing a string element [0]that is not defined, therefore not initialized. If you want to suppress them, try checking all uninitialized variables and give them a value according to, since you can do this with C.

-3
source

All Articles