
Untitled
By: a guest on
Jun 30th, 2012 | syntax:
None | size: 0.91 KB | hits: 12 | expires: Never
/**
* The only function of this statement is to return $poll_id if it's set. Which
* snippet would you use and why?
*
* I (@jrtashjian) prefer and wrote snippet 1. I like how contained the
* function is, and the fact I'm only calling the post() function once.
*
* Each snippet works correctly, this is just preference. I find it redundant
* to call the post() function more than once (as shown in snippet 3). I also
* find it unnecessary to create a variable ($poll_id) to store the result of
* function post() when I'll only be using it for the if statement.
*
* Let me know on Twitter, @jrtashjian.
*/
// Snippet 1
if( $poll_id = $this->EE->input->post('poll_id') )
{
return $poll_id;
}
// Snippet 2
$poll_id = $this->EE->input->post('poll_id');
if( $poll_id )
{
return $poll_id;
}
// Snippet 3
if( $this->EE->input->post('poll_id') )
{
return $this->EE->input->post('poll_id');
}