Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can someone please explain this syntax? 1

Status
Not open for further replies.

georgeocrawford

Technical User
Aug 12, 2002
111
GB
Hi,

Can someone please explain this syntax which I came across today:

Code:
$start = ( isset($_GET["start"]) ) ? $_GET["start"] : 0;

I understand what this does: $start is given the value of "start" as passed to the script from a form. If "start" is not passed, $start is set to "0".

However, I have never come across this syntax:

$x = ...... ? ...... : ... ;

Could someone tell me what this is called, so I can research it on php.net?

many thanks!

George
 
Thanks - sorted!

Took you a long time to reply - at least 1 minute!

George
 
sleipnir's link is the best information... but for the quick and lazy, look at it like this.

if (isset($_GET["start"])) {
$x = $_GET["start"];
} else {
$x = 0;
}

so........
$x = $1?$2:$3;

if ($1) {
$x = $2;
} else {
$x = $3;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top