strripos
returns an integer or false
, not true
. Switch the condition around and check for false
.
function checkParam($string){
$lookfor = "?";
$position = strripos($string, $lookfor);
if($position === false){
return "?";
}else{
return "&";
}
}
Also, there is no need for strripos
because you are only checking to see if the string exists. It does not matter if you find the first or last. Case is not an issue when you are searching for a question mark, either. I would use strpos
instead.