lundi 27 avril 2015

Can someone please tell me whether the conversion of code from conditional operator to if-else format is correct or not?

I've following snippet of code that is written using conditional operator :

$iPage=($this->request()->get('search') ? $this->request()->getInt('req4') : ($this->request()->getInt('req3') ? $this->request()->getInt('req3') : 1 ));

I converted this into if-else format as follows :

if($this->request()->get('search')) {
  $this->request()->getInt('req4')
} else {
  ($this->request()->getInt('req3')
}

Can some one please help me in telling that whether I've made the code conversion appropriately? If I've made any mistake in this conversion please correct the mistake and let me know the mistake.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire