comp.lang.php wrote:
That is a major fundamental problem then. Because if what you say is
true, then in order to set up a persistent environment to handle
potential collisions, one would have to have the PHP equivalent of
BEA/WebLogic as an application server running alongside your
application to ensure an ordered persistent-state environment, which
if I remember there is nothing out there unlicensed open-source in
PHP-dom, if wrong, point me in the right direction, please.
When working with PHP you should think it's way instead of forcing it to do
things it was not intended to. PHP is a good language for Web development
because it's philosophy closely mirrors the way the Web works; most other
languages have to adapt themselves somehow.
HTTP is a stateless protocol: when you load a HTTP response/page, which
gives you a state that was on the server the moment it was sent from there,
you have no idea what happens on the server -- the state there might
completely change and you and your browser will have no clue about it.
Consider a simple Web page (ie. no programming involved), and this scenario:
you open the page, say mypage.html, from my Web server, and while you're
reading it I delete it on the server. Although it exists no more (ie. its
state has changed), you still can see it until you try to load it again (or
even then for some time, depending on your browser's caching settings).
PHP is basically, as its new name nicely sums, a hypertext preprocessor:
when you request a HTTP address which calls a PHP script, it does nothing
else but preparing the output which will be sent by the server to your
browser. Historically, PHP is a simple procedural language, and each time
you call a script it executes anew, parsing and interpreting each
instruction one by one. There is no way -- and originally there was no
need -- to keep variables and its states in permanent memory, since most of
the time all persistent data was in databases or files (PHP has an excellent
mechanism to dynamically load and execute other PHP files, which are then
executed as if a part of the original script).
Through its evolution, PHP has gained various advanced features such as OOP,
but its essence -- it being the typical scripting language -- has remained
the same. With PHP there is no compile-time, everything is parsed and
evaluated only on run-time; and as it has no strong types, it is one of the
most dynamic languages in use: you can dynamicaly include libraries, assign
values or even load interpreter modules, or even such "perversions" like
variable variables, where you can decide which variable will be accessed (or
function/method called) by constructing its name dynamically.
Anyway, one should have in mind the specifics of the language working with,
regardless of which language it is. Basically, everything is possible with
every language: I have seen procedural applications written in Java (one
class, one main() method), as well as PHP OO bloatware with a hundred lines
of code and a separate template meta-language just for a simple Web site
(even without database!). So, when working in PHP you should think in PHP,
and ask more experienced programmers how to solve various issues (which
often turn out to be no issues at all).
Berislav