Re: php equivalent for `command`

From: Date: Tue, 17 Apr 2001 14:10:58 +0000
Subject: Re: php equivalent for `command`
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-48967@lists.php.net to get a copy of this message
The backtick operator " ` " is used like an exec() or passthru() function. But I know what you mean. For instance, try running this in a script: $n = 1; echo "The number is: $n++<br>"; echo "The number is: $n++<br>"; echo "The number is: $n++<br>"; PHP will not increment a variable inside of a string. However, now try this: $n = 1; echo "The number is: " . $n++ . "<br>"; echo "The number is: " . $n++ . "<br>"; echo "The number is: " . $n++ . "<br>"; But now try this: $n = 1; echo "The number is: " . ++$n . "<br>"; echo "The number is: " . ++$n . "<br>"; echo "The number is: " . ++$n . "<br>"; To do what you are wanting to do, just use the post-increment or pre-increment operators, just like in Perl. Just be aware that PHP will not do any mathematical functions on variables which are inside of a string. -- Plutarck Should be working on something... ...but forgot what it was. ""Greig, Euan"" <Euan.Greig@brann.com> wrote in message news:5CEAD14A5163D211A21B0008C724629401C8D802@ciren-mbx1.BRANN.CO.UK... > Is there a php equivalent for the use of ` (I think) in Unix/Perl? So for example echo "$x++" would first evaluate $x++ and then print the resulting value. > > Euan Greig > Technical Consultant > BRANN DATA > euan.greig@brann.com > 01285 645997 > > > > > > ************************************************************************** > Any opinions expressed in this email are those of the individual and > not necessarily the Company. This email and any files transmitted with > it, including replies and forwarded copies (which may contain alterations) > subsequently transmitted from the Company, are confidential and solely for > the use of the intended recipient. If you are not the intended recipient > or the person responsible for delivering to the intended recipient, be > advised that you have received this email in error and that any use is > strictly prohibited. > > ************************************************************************** > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#48967) next »