Click to See Complete Forum and Search --> : What doe sthis mean


andrew1234
07-08-2003, 09:52 AM
$a = ("php"=="php") ? "true":"false";

hi can you break this down into english please

i under stand == and $a but what i ? and :

thanks

pyro
07-08-2003, 10:37 AM
In english:

If "php" equals "php" set $a to "true". If "php" (or rather, the first condition) does not equal "php" (the second condition) set $a to false.

Basically, it is a simplified if statement that would be equivalent to this:

if ("php" == "php") {
$a = "true";
}
else {
$a = "false";
}

andrew1234
07-08-2003, 11:28 AM
thanks for th if statement
i understand that.

is it comman to use this shortened method?

andrew

pyro
07-08-2003, 11:38 AM
Not really -- at least not in PHP. It is more common in javascript. I think this is the first time I've seen it in PHP...

andrew1234
07-08-2003, 11:55 AM
dont you think that it is a bit silly of them to put it in a beginners php book.

anyway thanks for the help

Andrew

pyro
07-08-2003, 12:02 PM
It actually is good to know, as you can shorten certain bits of code considerably using it. But, as you said, it may be a bit premature in a beginners book...

andrew1234
07-08-2003, 12:10 PM
i checked out your site and it rocks..very nice design

I'm more of a flash html guy myself

i'd be interested what you think of this
http://www.hamandmushroom.co.za/test/andrew.swf

my action script is better than my php and java script

Andrew

pyro
07-08-2003, 12:21 PM
Thank you... :)

About your site...

That would make a better game than navigation system. Kinda hard to use, IMO. Also, all the pages that popped up gave a 404...

andrew1234
07-09-2003, 05:00 AM
and from a action script point of view?

what did you think?

Andrew

pyro
07-09-2003, 06:47 AM
I know very little action script, but it seemed to work well... :)