# reload() in Python, Possible in PHP?

- Thread: https://externals.io/message/8814
- Original archive: https://news-web.php.net/php.internals/8814
- Started by Andrew Heebner on 2004-03-28T20:57:22+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #8814 — Andrew Heebner — 2004-03-28T20:57:22+00:00

URL: https://externals.io/message/8814#8814

AFAIK, Python supports the reload() method, which lets you dynamically 
control includes while a script is running.

In PHP, even workarounds are tough to create reloadable modules for 
scripts, so, what other means are there to reload includes, and 
redeclare functions?

Thank you,
Andrew Heebner, EvilWalrus.com

---

## #8815 — Jon Parise — 2004-03-28T21:36:05+00:00

URL: https://externals.io/message/8814#8815 · In reply to: #8814

> AFAIK, Python supports the reload() method, which lets you dynamically 
> control includes while a script is running.

This is conceptually easier to implement in Python because a module is
its own namespace.  In PHP, the "stuff" that is included from another
file has no such common organization.
 
> In PHP, even workarounds are tough to create reloadable modules for 
> scripts, so, what other means are there to reload includes, and 
> redeclare functions?

If it's not already safe to include() your file multiple times, I
don't think adding a reload() function to PHP is going to improve your
situation all that much.  The engine would have to do a fair amount of
work to figure out how to "reload" the contents of the external
script.

-- 
Jon Parise (jon@php.net) :: The PHP Project (http://www.php.net/)

---

## #8817 — George Schlossnagle — 2004-03-28T22:40:28+00:00

URL: https://externals.io/message/8814#8817 · In reply to: #8815

> 
>
> > […]
>
> This is conceptually easier to implement in Python because a module is
> its own namespace.  In PHP, the "stuff" that is included from another
> file has no such common organization.
>
> > […]
>
> If it's not already safe to include() your file multiple times, I
> don't think adding a reload() function to PHP is going to improve your
> situation all that much.  The engine would have to do a fair amount of
> work to figure out how to "reload" the contents of the external
> script.

You can do this easily enough in an extension.  Combine the 
function/class tracking stuff that APC performs and internally use the 
overide_function() function from APD.  Obviously that would require a 
bit of glue to get it working, but the primitive facilities are all 
there.

I don't see any of that ever making it's way into PHP proper though.

George
