18591 Posts in 4875 Topics by 2285 members
General Questions
SilverStripe Forums » General Questions » Simple Question on Php
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 157 Views |
-
Simple Question on Php

13 October 2011 at 8:55pm
Hi, I am doing a tutorial 2, for the code below:
return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
What do the symbol '?' and ':' means? Thanks.
-
Re: Simple Question on Php

13 October 2011 at 9:31pm
I think it's called a ternary operator or conditional operator...
Read more about it here (scroll down a bit):
http://www.php.net/manual/en/language.operators.comparison.phpor in this blog post:
http://davidwalsh.name/javascript-shorthand-if-else-examplesCheers
-
Re: Simple Question on Php

13 October 2011 at 11:30pm
The :: allows you to use the function of the DataObject class without instantiating an actual object from it.
| 157 Views | ||
|
Page:
1
|
Go to Top |



