Apr 17, 2006 #1 wolf73 Programmer Feb 12, 2006 93 CA Hi, I see the following statement in php manual Constants may only be defined using the define() function, not by simple assignment; But I try the following code it works <?php $test= "abcd"; echo "$test"; ?>
Hi, I see the following statement in php manual Constants may only be defined using the define() function, not by simple assignment; But I try the following code it works <?php $test= "abcd"; echo "$test"; ?>
Apr 17, 2006 #2 rhyno2k IS-IT--Management Jun 9, 2001 222 US Wolf, In your example, $test is a variable, not a constant. Constants are defined as such: Code: define('TEST', "abcd"); The names of each describe their use. Constants are... constant. You can't change them. Variables are... variable. You can change them at any time. Upvote 0 Downvote
Wolf, In your example, $test is a variable, not a constant. Constants are defined as such: Code: define('TEST', "abcd"); The names of each describe their use. Constants are... constant. You can't change them. Variables are... variable. You can change them at any time.
Apr 17, 2006 Thread starter #3 wolf73 Programmer Feb 12, 2006 93 CA Thanks a lot .. Upvote 0 Downvote
Apr 18, 2006 #4 jpadie Technical User Nov 24, 2003 10,094 FR there is also a difference in scope and assignment. 1. you cannot assign a constant to the output of a function. 2. (to my mind most importantly) a constant is in the global scope. Upvote 0 Downvote
there is also a difference in scope and assignment. 1. you cannot assign a constant to the output of a function. 2. (to my mind most importantly) a constant is in the global scope.