Re: Variable Names

From: Date: Sat, 15 Jan 2000 15:24:11 +0000
Subject: Re: Variable Names
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-14652@lists.php.net to get a copy of this message
On Sat, 15 Jan 2000, Sterling Hughes wrote: > > ----- Original Message ----- > From: Chuck Daubenspeck <chuckd@bellatlantic.net> > To: <php-dev@lists.php.net> > Sent: Saturday, January 15, 2000 10:11 AM > Subject: [PHP-DEV] Variable Names > > > : > : Can anyone explain why the following: > : > : print "Success: $success<br>"; > : print "avs-code: $avs-code<br>"; > : print "auth-code: $auth-code<br>"; > : print "auth-msg: $auth-msg<br>"; > : > : would return: > : > : Success: no > : avs-code: -code > : auth-code: -code > : auth-msg: -msg > : > > Use > > print "avs-code: " . $avs-code . "<br>"; > > Otherwise PHP is evaluating $avs (not defined) and adding on the > constant -code. Using the string concatation operator should take care of > this That's actually inccurate. The simple explanation is that - is not a valid character for a variable name. Use _ instead. Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/

« previous php.dev (#14652) next »