note 48930 added to language.constants

From: Date: Wed, 12 Jan 2005 09:50:22 +0000
Subject: note 48930 added to language.constants
Groups: php.notes 
Request: Send a blank email to php-notes+get-83130@lists.php.net to get a copy of this message
To clarify from the previous post: When you define a constant, it becomes fixed at that point and is immutable. You can add variables - but the constant becomes the contents of that variable when the define is evaluated. If you try: define( "_A_TEXT" , "The value is " . $arr[$i] ); It would be evaluated ONCE with the current value of the $i index of array $arr. As the post pointed out, this is probably not what you want. You can easily create: define( "_A_TEXT" , "The value is "); .... echo _A_TEXT . $arr[$i]; Which would give you what you wanted: the constant string with the contents of the array appended. ---- Manual Page -- http://www.php.net/manual/en/language.constants.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48930 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48930&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48930&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48930&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48930&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48930&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48930&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48930&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#83130) next »