Re: Is there a way to redefine a constant?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



please keep the replies 'on list' ...

Khai Doan wrote:
> Sorry, I hit the Send button by mistake.  My problem is that these
> constant are defined at compile / startup time, before my script get to
> run.  In Perl, I can close STDERR and STDOUT and re-open them to any
> file at anytime.  In Perl, I can also use the BEGIN block.
> Is there a BEGIN block in PHP?

no - there is the auto_prepend_file ini setting - but that won't help you.

> 
> Can I prevent STDERR and STDOUT from being defined at startup time?  

no that I now of (unless you hack the source.)

> I am using CLI.

we figured as much.

can you not redirect stderr/stdout from the cmdline that starts your script?
otherwise you would be stuck with not using those constants and defining variables
that point to the stream(s) you want to output to ... AFAIT this should be neither
a problem nor a hack.

> 
> Thanks
> Khai
> Jochem Maas wrote:
> 
>> Khai wrote:
>>  
>>
>>> STDERR and STDOUT are defined as constants.  Is there a way to redefine
>>> these constants?
>>>   
>>
>> only if you use runkit (which is probably not recommended in
>> production environments):
>>
>>     http://php.net/runkit
>>
>> consider that constants are called as such for a reason. you should
>> consider that
>> it's probably better to define & use a couple of userland vars to
>> point to whatever
>> it is you want to point to - either that or redirect stdout/stderr in
>> the shell/cmdline that calls
>> your script instead.
>>
>>  
>>
>>> Thanks
>>> Khai
>>>
>>>   
>>
>>  
>>
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux