mercredi 18 mars 2015

PHP strange If Else loop output if i make exact opposite of current condition

what i am trying to do check the $_GET['mode'] for specific page types, if mode is favorites , rss or my_uploads page then dont show the RSS link like this



<?php
$mode = $_GET['mode'];
if($mode == 'favorites' || $mode == 'rss' || $mode == 'my_uploads'){
$RSS_link = null;
}else{
$RSS_link = create rss link logic here ;
}


then later showing the link to RSS FEED only if the link is created like this



<?=(isset($RSS_link)) ? '<a href="'.$RSS_link.'">RSS FEED</a>' : '' ;?>


the above code is working fine, and shows the RSS FEED Link only when pages are not favorites, rss,my_uploads


but if change the RSS creating condition like this.



<?php

if($mode != 'favorites' || $mode != 'rss' || $mode != 'my_uploads'){
$RSS_link = create rss link logic here ;
}else{
$RSS_link = null;
}


i.e. just changing the operators to opposite and moving if to else and else to if,



<?=(isset($RSS_link)) ? '<a href="'.$RSS_link.'">RSS FEED</a>' : '' ;?>


and then try to show the RSS FEED Link , it shows the link, no matter what the mode is set.


Why is this happening? How can i fix this ?


Aucun commentaire:

Enregistrer un commentaire