php global includes?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Isn't there some way to include some php code every time a php script is
run without having to put an include statement in the script?

All I want to do is set the ORACLE_HOME environmental variable on a
development machine. The servers have it compiled into php and it's
different on different machines. So programmers using the development
platform shouldn't have to set ORACLE_HOME.

I've been browsing the php documentation and doing google searches for an
hour already. I thought there was a config file somewhere where you could
put some php code and it would be run every time a script is run.

Did I dream that?

Re: php global includes?

Quoted text here. Click to load it

 Yes. auto_prepend_file configuration variable.

Quoted text here. Click to load it

 Wouldn't that be best set in your Apache startup script, or even /etc/profile
(or equivalent) per machine? Unless it's in exactly the same path on every
development machine... perhaps your development environment is well enough
regimented to guarantee the location though.

Quoted text here. Click to load it

 auto_prepend_file with a putenv() call is the closest match to what you're
asking, as far as I'm aware.

< Space: disk usage analysis tool

Re: php global includes?

Quoted text here. Click to load it

Well, maybe I should have asked that question first.

This works:

putenv("ORACLE_HOME=" . getenv("ORACLE_HOME"));
$conn = OCILogon ('username', 'password, 'host);
OCIdisconnect ($conn);

But it doesn't work without the putenv (getenv()). I get the standard
message indicating that it gives when ORACLE_HOME is not set.

Warning: ocilogon(): _oci_open_server: Error while trying to retrieve
text for error ORA-12154 in /home/jhe/public_html/index.php on line 17

So even though I can getenv  ORACLE_HOME, I still have to putenv it
before OCI will work. This seems to be standard behavior unless you
compile php with ORACLE_HOME.

Site Timeline