Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
tommyb
Hangin' Around



Joined: May 31, 2006
Posts: 49

PostPosted: Tue Feb 13, 2007 3:24 am Reply with quote

Hi,

Can someone give me an explanation of the following in terms of the format?
Code:


$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;



What is the use of the ? and the : here and does php.ini effect how you should use them? I saw something somewhere about rewriting statements like this differently but I don't understand the use of the question mark in this context.

Any help appreciated.
 
View user's profile Send private message
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6437

PostPosted: Tue Feb 13, 2007 6:39 am Reply with quote

Basically, it's like an IF statement, and it's called a Only registered users can see links on this board! Get registered or login!. The statement above could be written like this and it would have the same result:
Code:
if (isset($HTTP_GET_VARS['start']) ) {

  $start = intval($HTTP_GET_VARS['start']);
} else {
  $start = 0;
}

According to the documentation, for:
Code:
$first ? $second : $third

Quote:
If the value of the first subexpression is TRUE (non-zero), then the second subexpression is evaluated, and that is the result of the conditional expression. Otherwise, the third subexpression is evaluated, and that is the value.


To answer your specific question, the format of $start is an integer.

_________________
I search, therefore I exist...
Only registered users can see links on this board! Get registered or login!
 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©