Re: Define constants: awkward usage?
| From: | Jochem Maas | Date: | Wed, 26 Jan 2005 17:16:58 +0000 |
| Subject: | Re: Define constants: awkward usage? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-38365@lists.php.net to get a copy of this message | ||
tony wrote:
Hi all,you could try sprintf()/printf(): $output = sprintf('var fname = document.addrform.%s.value', FNAME ); or printf('var fname = document.addrform.%s.value', FNAME );I got this sets(20) of defined constants which using them as keys to anarrayeg define("FNAME", "fname"); farray = array( FNAME => "hello" ,...);my question is how do I insert that directly into a javascript(to dosome client validation)I need this: var fname = document.addrform.fname.valuevar fname = document.addrform.{FName}.value //don't work var fname = document.addrform.{'FName'}.value //don't work var fname = document.addrform.[FName].value //don't workI know this work, but messey $tmp = FNAME; var fname = document.addrform.{$tmp}.value
yes. :-) for... session varnames post/get varnames bitwise flags er...?I'am finding the use of define constants rather awkward. does anyonemake much use of them?
Thanks Tony