[thelist] Re: PHP includes/comparing string values - SOLUTION

Andrew Forsberg andrew at thepander.co.nz
Tue Mar 5 17:24:00 CST 2002

Hi Tim,

>Hi Andrew -- yes that did it. I have it working with:


>I appreciate you "spelling" it out without actually writing the code.

It makes everything easier huh? I'm not very good with flow charts,
but always try to write out a program in pseudo-code/pseudo-english
before hand (start with the most general chunks, then gradually fill
in the detail).

>I guess part of my problem was that I
>didn't realize that the variable declarations above the if/else were
>actually executed without being called!

Those fopen() functions return handlers you can use to access the
file, but the file's already been opened (or erased...). :)

>ANY comments as to how to make
>this more elegant would be appreciated.

I don't use filesystem functions very often at all, but the pseudo
code I suggested, and the final code does have a redundant include().
You remove both the include() statements, and put them outside the
if() block entirely, which means the else bit can get cut out as
well. i.e.:

if ($contents == $checkval) {
     $fw = fopen ($filename, "w");
     fwrite ($fw, $noting);
     fclose ($fw);

You don't need the clearstatcache thing either, it's only a cache for
the lifetime of the request.

Cheers, shout out with anything else too,


More information about the thelist mailing list