Eclipse PHP: variable undefined when array [message #1800455] |
Fri, 28 December 2018 18:21 |
Patrick Mising name Messages: 5 Registered: January 2010 |
Junior Member |
|
|
I copied and pasted Example #1 from the documentation for "define".
http://php.net/manual/en/function.define.php
I see an error that reads "Variable '$ANIMALS' is undefined" on the last echo line. This seems to happen whenever I try to reference a defined array. Am I doing something wrong? Is there some way to suppress this?
<?php
define("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world."
echo Constant; // outputs "Constant" and issues a notice.
define("GREETING", "Hello you.", true);
echo GREETING; // outputs "Hello you."
echo Greeting; // outputs "Hello you."
// Works as of PHP 7
define('ANIMALS', array(
'dog',
'cat',
'bird'
));
echo ANIMALS[1]; // outputs "cat"
?>
This might be considered similar to:
https://www.eclipse.org/forums/index.php/t/1094029/
|
|
|
Powered by
FUDForum. Page generated in 0.01694 seconds