View Single Post
Old 06-01-2014, 06:01 PM  
edgeprod
Permanently Gone
 
Industry Role:
Join Date: Mar 2004
Posts: 10,019
Quote:
Originally Posted by rowan View Post
I'd prefer to use a more specific function to reduce the chance of mixups. For example, strstr() returns only two possible values - false, or a non empty string. No chance of an ambiguous return there.
This is not a good solution for business use. strstr() is more memory-intensive than strpos(), and thus slower and less scalable. Here's some benchmarking:

http://net-beta.net/ubench/index.php?t=strpos1

From the PHP manual: "If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead."

You may want to research functions you use more carefully, if you're creating anything but the smallest programs for personal use. I wouldn't accept this choice from a contractor, personally.
edgeprod is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote