Reply to Re: [NEW] - from Java to PHP

Your name:

Reply:


Posted by Oliver Grδtz on 05/25/07 00:04

Luigi schrieb:
> Hi to all,
> I' d like to know if exists some sentences like this one below (in
> java) for PHP:
>
> JAVA:
> boolean isNull = (myObj == null) ? true : false;

Ignoring that this makes no sense since the expression in the
parantheses already yields a boolean value, I assume you are looking for
a PHP documentation of the ternary operator (which is not a Java
invention but has its roots in good old C). Here you are:

http://de.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary

If you want to be sure that the result of your expression is of a
certain type (since you put a "boolean" at the beginning of the line and
PHP does not have strict typing), you can add a cast to the desired type:

$isNull = (bool) ($myObj==null) ? true : false;

Of course you are triple ensuring what can be accomplished by the PHP
engine internal function:

$isNull = is_null($myObj);

*g*


OLLi

--
Sidney: "Are you sure you don't wanna stay for dinner."
Eric: "I'd love to but... I gotta save the world."
[Alias 402]

[Back to original 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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация