Welcome Guest, Not a member yet? Register   Sign In
If, then, else shorthand (aka ternary or conditional operator)?
#4

[eluser]n0xie[/eluser]
We use both but for different forms of if. We try to make a difference between control structure and a simple check structure. A control structure decides the 'flow' of the application based on some checks. A simple check just evaluates some conditions to see if it should proceed with whatever it is doing.

Example:
Code:
// control structure
if (some condition is true)
{
  execute this piece of code
}
else
{
  do something completely different
}

// example in codeigniter
if ($this->form_validation->run() == FALSE)
{
  // show form
}
else
{
  // process submitted form
}

Code:
// simple check
$data = (isset($data)) ? $data : array();
$title = ($this->input->post($title)) ? $this->input->post($title, TRUE) : lang('untitled');


Messages In This Thread
If, then, else shorthand (aka ternary or conditional operator)? - by El Forum - 10-21-2010, 02:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB