You are here: Re: short if else « PHP Programming Language « IT news, forums, messages
Re: short if else

Posted by Mladen Gogala on 12/28/05 18:33

On Wed, 28 Dec 2005 11:51:29 +0100, Moneypenny wrote:

> All gives a parse error.
>
> How can i do this?
>
> Tnx.

Well, everything else aside, there is a trick you can use:

$ cat /tmp/ttt
#!/usr/local/bin/php
<?php
$test=1;
$test == 1 ? eval('$do = true; $who = "me";') : $do = false;
echo "Do: $do Who:$who\n";
?>

$ php /tmp/ttt
Do: 1 Who:me
$

Of course, the code would be much more readable with if/then,
just as the others have told you.

--
http://www.mgogala.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация