Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » Eclipse PHP: variable undefined when array
Eclipse PHP: variable undefined when array [message #1800455] Fri, 28 December 2018 18:21
Patrick Mising name is currently offline Patrick Mising nameFriend
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/
Previous Topic:Windows firewall?
Next Topic:Timeout problem
Goto Forum:
  


Current Time: Tue Apr 20 11:46:09 GMT 2021

Powered by FUDForum. Page generated in 0.01724 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top