On May 19, 2011, at 3:16 PM, Alex Nikitin wrote:
> PHP_SELF requires no processing (i.e. there is no need to do basename())
>
> strcmp is binary-safe, i prefer and recommend using string-safe comparison
> functions for strings... here is an example of why:
>
> $value = 0;
> if($value=="not zero") {
> echo "oopsie, how did this happen, lets see how this works with strcmp
> (or === which i would advise)";
> if(strcmp($value, "not zero") == 0) {
> echo "You wont see this";
> } else {
> echo "Because strcmp works correctly";
> }
> }
>
> you can also use the exact comparator ===, as it compares types, it would
> work well as well. Infact if you dont need to determing anything about the
> string, i would suggest using the === operator as it is significantly
> faster:
>
> timed: 0m0.724s
> <?php
> for($i=0; $i<=10000000; $i++){
> if(1 === "submit") {
> continue;
> }
> }
>
> timed: 0m4.785s
> <?php
> for($i=0; $i<=10000000; $i++){
> if(strcmp(1, "submit")==0) {
> continue;
> }
> }
>
> --
> The trouble with programmers is that you can never tell what a programmer is
> doing until it’s too late. ~Seymour Cray
I almost exclusively use ===.
Regards,
-Josh
____________________________________
Joshua Kehn | [email protected]
http://joshuakehn.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php