strpos - strripos does not seems to work for me -


i'm trying use strripos in fact try add parameter url fro translating website,

the fact not on url requested have parameter can not everytime &lang=en need ?lang=en

i've tried function using strripos that

/**  * fonction qui renvoit le bon caractère en tant que paramètre  * @param type $string  * @return string  */ function checkparam($string){     $lookfor = "?";     $position = strripos($string, $lookfor);     if($position === true){     return "&";     }else{     return "?";     } } 

i have example url : $url_courante = $_server['server_name'].$_server['request_uri'];

which give me that

www.mydomain.eu/index.php?p=nos-produits 

but not recognize ? in string, returns me false , can not set lang url.

anykind of appreciated.

strripos returns integer or false, not true. switch condition around , check false.

function checkparam($string){     $lookfor = "?";     $position = strripos($string, $lookfor);     if($position === false){         return "?";     }else{         return "&";     } } 

also, there no need strripos because checking see if string exists. not matter if find first or last. case not issue when searching question mark, either. use strpos instead.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -