From: [EMAIL PROTECTED]
Operating system: Windows 2000
PHP version: 4.1.1
PHP Bug Type: Scripting Engine problem
Bug description: Use undefined global variable in function - not warning
I try use global variable in function. When variable is not defined and I
have set error_reporting to E_ALL, PHP doesn't
report, that variable is not defined, but silently define it.
<?php
// Test for use global variable if variable not defined.
// PHP don't write any warning
ini_set("error_reporting", E_ALL);
function test_me(){
global $test_var;
return $test_var;
};
// Next line report message "Undefined variable..." - It's ok.
echo "Following message 'Undefined variable...' is OK! It's feature.\n";
echo "Test var (direct test_var): ".$test_var."\n";
// Next line DOESN'T report message "Undefined variable" - It's bug?
echo "Is after this message, message about 'Undefined variable...'? If not
- PHP bug\n";
echo "Test var (test_me): ".test_me()."\n";
// Next line DOESN'T report message "Undefined variable" - It's bug?
echo "Test var (direct test_var): ".$test_var."\n";
echo "Now defining test_var\n";
$test_var = "I am here!";
echo "Test var (test_me): ".test_me()."\n";
?>
Is this problem known?
--
Edit bug report at http://bugs.php.net/?id=15805&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=15805&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=15805&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=15805&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=15805&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=15805&r=support
Expected behavior: http://bugs.php.net/fix.php?id=15805&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=15805&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=15805&r=submittedtwice