Re: newbie Q: How to say, "if the fileNAME is equal to...", or better yet, "if the fileNAME ends with '.jpg'"?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




if (stripos(strrev($file), "gpj.") === 0) {
echo $file; }

note the ===, 3 equals signs here is very important! check the docs for why.

== means 'equals', and === means 'is identical to'.
Seems like they would do the same thing when comparing '0' to 'the position in the string where that substr is found'. Why not?

0 can mean false in php:

$found = 0;
....
if (!$found) {
  echo "File not found";
}

If a substr comparison matches at char 0:

$string = '12345';
$pos = substr($string, '1');

then without the '===' it would give the wrong result as $pos would be converted to false in this example.

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux