Skip to main content
added 4 characters in body
Source Link
chaos
  • 124.8k
  • 34
  • 306
  • 310

I do believe that the ternaryconditional operator is the shortcut :) For the sake of saving function calls and readability, I suggest saving the value to a variable first.

$some_value = $this->db->get_where('my_db',array('id'=>$id))->row()->some_value); $output = $some_value ? $some_value : "Some Value Not Set"; echo $output; 

I do believe that the ternary operator is the shortcut :) For the sake of saving function calls and readability, I suggest saving the value to a variable first.

$some_value = $this->db->get_where('my_db',array('id'=>$id))->row()->some_value); $output = $some_value ? $some_value : "Some Value Not Set"; echo $output; 

I do believe that the conditional operator is the shortcut :) For the sake of saving function calls and readability, I suggest saving the value to a variable first.

$some_value = $this->db->get_where('my_db',array('id'=>$id))->row()->some_value); $output = $some_value ? $some_value : "Some Value Not Set"; echo $output; 
Source Link
Paulo
  • 4.4k
  • 2
  • 22
  • 20

I do believe that the ternary operator is the shortcut :) For the sake of saving function calls and readability, I suggest saving the value to a variable first.

$some_value = $this->db->get_where('my_db',array('id'=>$id))->row()->some_value); $output = $some_value ? $some_value : "Some Value Not Set"; echo $output;