Jump to content

Conditional statement shorthand...


cgm225

Recommended Posts

So, I am using the following line of code...

 

$_POST ? $comments->addComment(): null;

 

...so, what happens is, if there is POST data, a method is executed.  However, if not, then nothing happens.  However, is there a way to write this where the null does not need to be included? 

Link to comment
https://forums.phpfreaks.com/topic/123805-conditional-statement-shorthand/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.