Skip to content
Advertisement

PHP “||” is returning the wrong value

I am making an upload script for a music-related thing i am building.
I check whether the file is an MP3 or an OGG, but even if it IS, php will return true on this and say that it isnt on either of these checks.
Here’s some example code:

$ft = "mp3";
if($ft != "mp3" || $ft != "ogg") { echo "not an ogg / mp3"; }

What it returns:

not an ogg / mp3

If i am doing something wrong, i am more than glad to be crapped on by Stack Overflow this time, cuz at least i know i did something stupidly wrong.

Advertisement

Answer

|| operator means or so if one of the following conditions is true it will do the action of the condition , you need to change it to && which means the both condition should be true to do the action

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement