[php] Eliminate use of unset constants in example
This generates a warning with PHP 7.3 which apparently will become an error in the future. We're just checking that a constant that should not be define indeed isn't, which we can achieve more cleanly using get_defined_constants() instead.
This commit is contained in:
parent
c199b173f8
commit
ebc9e6ad9f
1 changed files with 5 additions and 9 deletions
|
|
@ -12,16 +12,12 @@ print "EXPR = " . EXPR . " (should be 48.5484)\n";
|
|||
print "iconst = " . iconst . " (should be 37)\n";
|
||||
print "fconst = " . fconst . " (should be 3.14)\n";
|
||||
|
||||
if (EXTERN!="EXTERN") {
|
||||
print "EXTERN = " . EXTERN . " (Arg! This shouldn't print anything)\n";
|
||||
} else {
|
||||
print "EXTERN defaults to 'EXTERN', it probably isn't defined (good)\n";
|
||||
$c = get_defined_constants();
|
||||
if (array_key_exists("EXTERN", $c)) {
|
||||
print "EXTERN = " . $c["EXTERN"] . " (Arg! This shouldn't print anything)\n";
|
||||
}
|
||||
|
||||
if (FOO!="FOO") {
|
||||
print "FOO = " . FOO . "(Arg! This shouldn't print anything)\n";
|
||||
} else {
|
||||
print "FOO defaults to 'FOO', it probably isn't defined (good)\n";
|
||||
if (array_key_exists("FOO", $c)) {
|
||||
print "FOO = " . $c["FOO"] . " (Arg! This shouldn't print anything)\n";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue