Can someone tell me what the condition is in this php statement?
return $node->type == 'article' ? mymodule_page_article($node) : mymodule_page_story($node);
I'm sorry if this is not the place to ask such a simple question but I'm finding it difficult to look up specific code structure (especially when I don't know the name of it).
This is a ternary operator.
It's equivalent to
if( $node->type == 'article' ) {
return mymodule_page_article($node);
} else {
return mymodule_page_story($node);
}
What it does is: if the stuff before the ?
is true, return the result of the expression in the first clause (the stuff between ?
and :
). If it's false, then it returns the result of the second clause (the stuff after the :
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With