Re: Globally runnable PHP script
| From: | Michael Kimsal | Date: | Wed, 18 Oct 2000 00:28:14 +0000 |
| Subject: | Re: Globally runnable PHP script | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-20743@lists.php.net to get a copy of this message | ||
I see you've had a few replies on this already, and they address the
direct part of your question, but leave something out.
The 'autoprepend' thing does what you ask, sort of. In ASP and CF
there is one file that gets executed - it's defined by name. In PHP,
you define that file, so the thinking needs to be reversed a bit.
However, what the 'application' concept gets you in ASP extends beyond
the global.asa file. Yes, it sets variables that can be accessed, and an
autoprepend will also define variables for you. The difference is that
in ASP, those variables are then accessible to all ASP scripts,
and changeable as well.
global.asa
application("myval") = 1
foo.asp
response.write application("myval")
application("myval")=2
bar.asp
response.write application("myval")
running foo.asp, then bar.asp, bar.asp would return "2", not "1".
To accomplish *this* functionality (if you're converting from ASP or CF)
you'd need to write some pseudo "application-var" code handling
in whatever php script you 'auto-prepend'. This would be cumbersome,
but I'm sure the execution would be acceptable. You'd also need
to write another PHP script to auto-postpend (what's that term) or
put a common footer on every script that would write the application vars
state to a common area (database or file area).
Again, cumbersome to do, but it would be nice to have once it's in place.
The clash of two application vars being updated at the same time might,
however, be an issue. Perhaps shared-memory functions if that's a concern.
Srinivasan Ramakrishnan wrote:
> Hi,
>
> In ASP there is global.asa, in CFML there is application.cfm, what is the
> equivalent in PHP?
>
> In other words, is there a special file I can execute before the accessed
> PHP file is parsed.
>
> -Srini
>
--
==========================
Michael Kimsal
http://www.tapinternet.com
734-480-9961