Govinda wrote:
if (true == ($file="xxxx.jpg")) {
Watch out for this!
You're doing a test that is an assignment..
You are assigning the value "xxxx.jpg" to the variable $file. You are
then comparing this to the value "true" and (due to the loose variable
types) this succeeds.
Although some people consider it ugly, it is a *very* good practice to
put the constants on the left hand side of the comparison like so:
if (true == ("xxxx.jpg"=$file)) {
I've kept your error above, but if you try and run this code, you will
get a syntax error.
The correct comparison is to do:
if (true == ("xxxx.jpg"==$file)) {
Note the double ='s signs.
As you have VB experiences, this is different, but follows the
conventions of a lot of languages (C, C++, C# etc.). VB inferred whether
you wanted assignment or comparison depending on the context, but this
came at the expense of not being able to nest complex statements.
Of course your example above could probably have been achieved by doing
if (file_exists("xxxx.jpg")) {
but that's beside the point :)
Col
--
Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/
Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php