php - Stripos issues in php4 -


please have following function contact form, shows following error "fatal error: call undefined function: stripos() in" how can fix it

function checkemail($vemail) {                         $invalidchars ="/:,;" ;                      if(strlen($vemail)<1) return false;                                         //invalid characters                     $atpos = stripos($vemail,"@",1);                                    //first position of @                     if ($atpos != false) $periodpos = stripos($vemail,".", $atpos);         //if @ not found null . position                     ($i=0; $i<strlen($invalidchars); $i++) {                            //check bad characters                          $badchar = substr($invalidchars,i,1);       //pick 1                         if(stripos($vemail,$badchar,0) != false)    //if found                             return false;                     }                     if ($atpos == false)                            //if @ not found                         return false;                            if ($periodpos == "")                           //if . null                         return false;                     if (stripos($vemail,"@@")!=false)               //if @@ found                         return false;                     if (stripos($vemail,"@.") != false)             //@.is found                         return false;                     if (stripos($vemail,".@") !=  false)            //.@ found                         return false;                      return true;                     } 

as can see the documentation, stripos() exists in php5. anyways, code doesn't need chack case-insensitive because checks . @ / : , ; - can replace stripos() strpos().

you add own stripos() codebase, wich thoe following (using strtolower() , function_exists()):

if(!function_exists("stripos")){   function stripos($haystack, $needle, $offset = 0){     return strpos(strtolower($haystack), strtolower($needle), $offset)   } } 

note basic replacemend , might not give same result real stripos() in each end every case. it's valid basic usage, havn't done broad tests.


Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -