PDA

View Full Version : if extension exists?


tgillespie
03-24-2005, 06:25 PM
Need a little help writing an if statement to check if a certain file with the following extension is present.

if(file_exists("/" . * . ".jpg")) I realize php cannot use *as a wild card character, but was just curious as to how someone woulduse a wildcard file name with a .jpg extension this this statement.

filburt1
03-24-2005, 08:30 PM
<a href="http://us4.php.net/manual/en/function.readdir.php" target="_blank">http://us4.php.net/manual/en/function.readdir.php</a> ?

deathemperor
03-24-2005, 10:51 PM
what does !== mean ?

Brad
03-25-2005, 12:21 AM
what does !== mean ?
Basicly $x !== $y means $x is not equal to $y

noppid
03-25-2005, 12:28 AM
It means that if the variables are not cast as the same type they will eval as not equal.

filburt1
03-25-2005, 01:10 AM
what does !== mean ?
If they are not the same exact value.

== compares string representations; != is the inverse
=== compares the exact values depending on the type; !== is the inverse

For example:

123 == "123" // is true
123 === "123" // is false; the first is numeric, the second is a string

tgillespie
03-25-2005, 03:40 AM
Thanks filburt. Readdir was exactly what I was looking for.

sabret00the
03-25-2005, 03:50 PM
can i just ask what's the difference between != and !==?

nevermind it appears to be the same as == and === :-S

AN-net
03-25-2005, 04:28 PM
so wait...
== is used for numerics and === is used for strings. woops^.^

Guest190829
03-25-2005, 06:13 PM
so wait...
== is used for numerics and === is used for strings. woops^.^

No, I think == means equal, while === means identical. It's not based on whether it's a string or numerical value.

In filburt's example


123 == "123" // is true
123 === "123" // is false; the first is numeric, the second is a string


123 is equal to "123" // is true
123 is identical to "123" // is false, the quotations indicate the 123 as a string.

I could be wrong though. I'm still learning.

filburt1
03-25-2005, 06:16 PM
Manual == good.

http://us3.php.net/manual/en/language.operators.comparison.php

Marco van Herwaarden
03-25-2005, 07:45 PM
Simple put == means it holds the same value, === is also checking on the type.

deathemperor
03-28-2005, 03:13 PM
nice points, thanks guys