[thelist] PHP include

Luther, Ron Ron.Luther at hp.com
Fri Aug 6 15:23:10 CDT 2010


>>o.k so if I wanted my scenario to work, what should I do? Is there any way?

Hi Davoud,

More of a minor variation on Jack's theme than anything radically different, but I think I might do this all on the server side by dynamically writing the "file_to_include.php" file.

(1) Pass the parameters you want to base your include on to the server.
(2) Put all of your condition testing logic in this server processing file and write, as output, the "file_to_include.php" file.  That could write out as much, or as little, code as you want.  I would set a default to a single commented out line to avoid null include file errors, though.  [This server-side could be executed via a form-processing page, or a database trigger/sproc-y thing, or whatever.]
(3) Send the user to some page that includes this newly created "file_to_include.php" file.

That should work.  [1]


[1] I'm not thinking you need to go that far or scale to that level, but I think that if you want to get *really* tricky you could write these include files out uniquely for each user session.  Just don't forget to implement a clean-up routine once the need for the 'old' include file goes away.

More information about the thelist mailing list