| 
	
 | 
 Posted by Richard Lynch on 06/14/62 11:07 
Michael wrote: 
> I'm trying to use stripos as a faster and less resource-intensive 
> alternative to preg_match with the i flag, but I'm getting some strange 
> behavior. 
> 
> Here's a test script that demonstrates the problem: 
> --- 
> <?php 
> $days = array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"); 
> foreach ($days as $d) { 
>      echo "Checking day: $d"; 
>      if (stripos($d, 'T') === 0) { 
>          echo "Day is Tuesday or Thursday"; 
>      } else { 
>          echo "Day is MWFSS"; 
>      } 
> } 
> ?> 
> --- 
> When I run this as-is, it prints "Checking day: Mon" and stops. When I 
> change stripos to strpos, it runs all the way through doing what it's 
> supposed to. It's as if stripos calls 'die' somehow and strpos doesn't. 
> 
> AFAIK, stripos should behave exactly like strpos except 
> case-insensitively. So in the function above, it should make absolutely 
> no difference which one I use. 
 
stripos only exists in PHP 5. 
 
You are probably running PHP 4. 
 
You also are hiding/re-directing your error messages somewhere, and have 
not gotten into the habit (yet) of reading the error log. 
 
You'll need to read php.ini to be certain, and I can't REALLY be sure 
where your error_log is on your server, but if you are completely confused 
by what I've typed, try this: 
 
tail -f /usr/local/apache/logs/error_log 
 
Dollars to donuts says you'll find something about stripos not being 
defined, once you find the error output. 
 
For penance, you will practice starting your work-day with: 
"tail -f /path/to/your/log" 
several times right now, and be sure you start your work-day that way for 
the rest of the week 
:-) 
 
--  
Like Music? 
http://l-i-e.com/artists.htm
 
  
Navigation:
[Reply to this message] 
 |