Re: include
| From: | Tommy Pham | Date: | Sun, 20 Nov 2011 10:36:15 +0000 |
| Subject: | Re: include | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-315772@lists.php.net to get a copy of this message | ||
On Sat, Nov 19, 2011 at 2:16 PM, Tim Streater <tim@clothears.org.uk> wrote:
> At the moment I'm using an instance of apache to run PHP scripts, as and when required via
> AJAX. Having got some understanding of web sockets, I'm minded to look at having a small server
> to execute these functions as required. The scripts, some 50 or so, are only about 300kbytes of
> source code, which seems small enough that it could all be loaded with include, as in:
>
> <?php
> $fn = 'wiggy.php';
> include $fn;
> ?>
>
> This appears to work although I couldn't see it documented.
>
> I'd also like to be able to replace a module without restarting the server. I
> couldn't see a way to drop an included file, do I therefore take it that there is none? Failing
> that, is there a good way to dynamically replace parts of a PHP program, possibly using runkit?
>
> --
> Cheers -- Tim
>
>
Tim,
I think you're approaching this the wrong way.
1) have a clear understanding of PHP - syntax, capabilities, etc.
2) have a clear understand of what you're intending to do -
application's function/purpose, features, manageability,
expandability, portability, etc...
3) understand design patterns
What your asking is practically impossible in any programming language
akin to 'how to un-import packages in Java' or 'how to un-using
namespace in C#'. If you don't want to use it, don't include it ;)
If this is running as web app, you can use header [1] and pass the
criteria for next phase of the operation as URL parameters. But doing
this is going to kill the server side with too many unnecessary round
trips. Which clearly demonstrates point 2 and 3. You should look
into Interfaces, and Abstract under OOP [2].
HTH,
Tommy
[1] http://php.net/function.header
[2] http://php.net/language.oop5