Usage of ||, OR in PHP
- by shin
I have the following code which redirect pages depends on $path.
...
$path = $this->uri->segment(3);
$pathid = $this->uri->segment(4);
if($path=='forsiden'){
redirect('','refresh');
}elseif($path =='contact'){
redirect('welcome/kontakt','refresh');
}elseif($path =='illustration'){
$this->_gallery($path,$pathid);
}elseif($path =='webdesign'){
redirect('welcome/webdesign','refresh');
}elseif($path==('web_tjenester' || 'webdesigndetails' ||
'vismahjemmeside' || 'joomla' || 'vismanettbutikk' ||
'vpasp' || 'artportfolio')){
...
CODE A
...
}else{
...
CODE B
...
}
I am not getting right results with
$path==('web_tjenester' || 'webdesigndetails' ||
'vismahjemmeside' || 'joomla' || 'vismanettbutikk' ||
'vpasp' || 'artportfolio')
contact, illustration, gallery and webdesign are redirected and working alright.
However all other pages are added CODE A.
I am expecting CODE A only when $path is web_tjenester', 'webdesigndetails', 'vismahjemmeside', 'joomla', 'vismanettbutikk', 'vpasp' or 'artportfolio'.
Could anyone point out my mistake and correct me please?
Thanks in advance.
--UPDATE--
The following works, but is there any ways shorten the code?
I am repeating ($path==..).
elseif(($path=='web_tjenester') || ($path=='webdesigndetails') ||
($path=='vismahjemmeside') || ($path=='joomla') || ($path=='vismanettbutikk') ||
($path=='vpasp') || ($path=='artportfolio')){