FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » display_errors stdout not working in a .htaccess file
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
display_errors stdout not working in a .htaccess file [message #170573] Mon, 08 November 2010 21:35 Go to next message
yawnmoth is currently offline  yawnmoth
Messages: 5
Registered: September 2010
Karma: 0
Junior Member
I have a .htaccess file that contains only one line:

php_flag display_errors on

Only problem: Errors aren't being displayed as I'd expect. Any ideas
as to why? Is there some setting in httpd.conf that can be used to
prevent errors from displaying?
Re: display_errors stdout not working in a .htaccess file [message #170575 is a reply to message #170573] Mon, 08 November 2010 22:01 Go to previous messageGo to next message
yawnmoth is currently offline  yawnmoth
Messages: 5
Registered: September 2010
Karma: 0
Junior Member
On Nov 8, 3:35 pm, yawnmoth <terra1...@yahoo.com> wrote:
> I have a .htaccess file that contains only one line:
>
> php_flag    display_errors  on
>
> Only problem: Errors aren't being displayed as I'd expect.  Any ideas
> as to why?  Is there some setting in httpd.conf that can be used to
> prevent errors from displaying?

If PHP was running as CGI I'd have to modify php.ini in the
appropriate directory (or the "root" php.ini) but PHP isn't running as
CGI - it's running as mod_php.

Also, according to phpinfo(), display_errors's local value is On while
the master value is Off. So why aren't I seeing any errors?
Re: display_errors stdout not working in a .htaccess file [message #170576 is a reply to message #170573] Mon, 08 November 2010 22:02 Go to previous messageGo to next message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma: 0
Senior Member
yawnmoth schrieb:
> I have a .htaccess file that contains only one line:
>
> php_flag display_errors on
>
> Only problem: Errors aren't being displayed as I'd expect.

// Does this produce error output?
ini_set( 'display_errors', 1 );
error_reporting( E_ALL | E_STRICT );
echo $noSuchVar;

Check the output of phpinfo():
- does display_errors have the expected value there?
- what's the value of error_reporting?
And does PHP run as an Apache module or (Fast)CGI? In the latter case,
you cannot set php directives in .htaccess.

Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
Re: display_errors stdout not working in a .htaccess file [message #170577 is a reply to message #170573] Mon, 08 November 2010 23:08 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 11/8/2010 4:35 PM, yawnmoth wrote:
> I have a .htaccess file that contains only one line:
>
> php_flag display_errors on
>
> Only problem: Errors aren't being displayed as I'd expect. Any ideas
> as to why? Is there some setting in httpd.conf that can be used to
> prevent errors from displaying?

What about error_reporting?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: display_errors stdout not working in a .htaccess file [message #170579 is a reply to message #170576] Mon, 08 November 2010 23:43 Go to previous messageGo to next message
Jim Wigginton is currently offline  Jim Wigginton
Messages: 2
Registered: November 2010
Karma: 0
Junior Member
On Nov 8, 4:02 pm, Thomas Mlynarczyk <tho...@mlynarczyk-webdesign.de>
wrote:
> yawnmoth schrieb:
>
>> I have a .htaccess file that contains only one line:
>
>> php_flag    display_errors  on
>
>> Only problem: Errors aren't being displayed as I'd expect.
>
> // Does this produce error output?
> ini_set( 'display_errors', 1 );
> error_reporting( E_ALL | E_STRICT );
> echo $noSuchVar;

That does indeed yield an error.

> Check the output of phpinfo():
> - does display_errors have the expected value there?

The local value is on wheras the master value is off.

> - what's the value of error_reporting?

Local value is 0, master value is 30711.

> And does PHP run as an Apache module or (Fast)CGI? In the latter case,
> you cannot set php directives in .htaccess.

The server API is "Apache 2.0 Handler". I assume that's an Apache
module.
Re: display_errors stdout not working in a .htaccess file [message #170580 is a reply to message #170577] Mon, 08 November 2010 23:46 Go to previous messageGo to next message
Jim Wigginton is currently offline  Jim Wigginton
Messages: 2
Registered: November 2010
Karma: 0
Junior Member
On Nov 8, 5:08 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 11/8/2010 4:35 PM, yawnmoth wrote:
>
>> I have a .htaccess file that contains only one line:
>
>> php_flag    display_errors  on
>
>> Only problem: Errors aren't being displayed as I'd expect.  Any ideas
>> as to why?  Is there some setting in httpd.conf that can be used to
>> prevent errors from displaying?
>
> What about error_reporting?

I've tried setting error_reporting with the following:

php_flag error_reporting 30719
php_flag error_reporting E_ALL

The former is the constant of E_ALL per <http://php.net/manual/en/
errorfunc.constants.php>. Neither work. phpinfo() says that the
local value of error_reporting is 0 whereas the master value is 30719
so I'm thinking that's the problem. I just don't know where
error_reporting is getting overwritten. The file I'm accessing is in
the exact same directory as the .htaccess file.
Re: display_errors stdout not working in a .htaccess file [message #170581 is a reply to message #170580] Tue, 09 November 2010 00:00 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 11/8/2010 6:46 PM, Jim Wigginton wrote:
> On Nov 8, 5:08 pm, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 11/8/2010 4:35 PM, yawnmoth wrote:
>>
>>> I have a .htaccess file that contains only one line:
>>
>>> php_flag display_errors on
>>
>>> Only problem: Errors aren't being displayed as I'd expect. Any ideas
>>> as to why? Is there some setting in httpd.conf that can be used to
>>> prevent errors from displaying?
>>
>> What about error_reporting?
>
> I've tried setting error_reporting with the following:
>
> php_flag error_reporting 30719
> php_flag error_reporting E_ALL
>
> The former is the constant of E_ALL per<http://php.net/manual/en/
> errorfunc.constants.php>. Neither work. phpinfo() says that the
> local value of error_reporting is 0 whereas the master value is 30719
> so I'm thinking that's the problem. I just don't know where
> error_reporting is getting overwritten. The file I'm accessing is in
> the exact same directory as the .htaccess file.

You can't use E_ALL in your .htaccess file - it's only known to PHP, not
to Apache.

But your problem is that php_flag is just that - a flag, on or off.
What you need is php_value for error_reporting.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: display_errors stdout not working in a .htaccess file [message #170600 is a reply to message #170579] Tue, 09 November 2010 19:40 Go to previous messageGo to next message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma: 0
Senior Member
Jim Wigginton schrieb:

>> // Does this produce error output?
>> ini_set( 'display_errors', 1 );
>> error_reporting( E_ALL | E_STRICT );
>> echo $noSuchVar;
>
> That does indeed yield an error.

So it's not an "output problem" but a config problem.

[display_errors]
> The local value is on wheras the master value is off.

Then there should be error output, unless error_reporting "forbids" it
(see farther below). (Very stupid question: are you *sure* that an error
is indeed produced? What happens if you remove either one or both of the
the ini_set() and error_reporting() lines in my above test code?)

[error_reporting]
> Local value is 0, master value is 30711.

That means somewhere the error_reporting was switched off. Could have
been either via another .htaccess/httpd.conf setting or by an
error_reporting( 0 ) somewhere in your code (an included script/library
perhaps).

> The server API is "Apache 2.0 Handler". I assume that's an Apache
> module.

Yes.

Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
Re: display_errors stdout not working in a .htaccess file [message #170601 is a reply to message #170579] Tue, 09 November 2010 19:46 Go to previous messageGo to next message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma: 0
Senior Member
Jim Wigginton schrieb:
[error_reporting]
> Local value is 0, master value is 30711.

By the way: a value of 30711 would exclude E_NOTICE and E_STRICT. Try
30719 instead to include E_NOTICE or 32767 to include "really all".

Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
Re: display_errors stdout not working in a .htaccess file [message #170602 is a reply to message #170601] Tue, 09 November 2010 19:53 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(Thomas Mlynarczyk)

> Jim Wigginton schrieb:
> [error_reporting]
>> Local value is 0, master value is 30711.
>
> By the way: a value of 30711 would exclude E_NOTICE and E_STRICT. Try
> 30719 instead to include E_NOTICE or 32767 to include "really all".

-1 should do to include all.

Micha
Re: display_errors stdout not working in a .htaccess file [message #170603 is a reply to message #170581] Tue, 09 November 2010 19:53 Go to previous messageGo to next message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma: 0
Senior Member
Jerry Stuckle schrieb:
> But your problem is that php_flag is just that - a flag, on or off. What
> you need is php_value for error_reporting.

Indeed. But I wonder what PHP will do if a "value" directive is set
using php_flag? The OP wrote that the local value was 0 and the master
30711 (which excludes notices, btw. and would therefore not have shown
any error in my example script). Could it be that

php_flag error_reporting <non-flag-or-invalid-value>

will have the same effect as

php_value error_reporting 0

instead of raising an error and/or keeping the master value?

Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
Re: display_errors stdout not working in a .htaccess file [message #170604 is a reply to message #170579] Tue, 09 November 2010 19:56 Go to previous messageGo to next message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma: 0
Senior Member
Me again ;-)

Two more things to try:
- Set display_startup_errors in your php.ini to see if PHP complains
about any invalid settings (and don't forget to disable it again
afterwards).
- Remember that you must restart Apache for any new httpd.conf or
php.ini settings to take effect.

Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
Re: display_errors stdout not working in a .htaccess file [message #170605 is a reply to message #170602] Tue, 09 November 2010 20:09 Go to previous messageGo to next message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma: 0
Senior Member
Michael Fesser schrieb:
>> [error_reporting]
> -1 should do to include all.

Correct. But personally I prefer the more explicit E_ALL | E_STRICT.
And, strictly speaking, one should not rely upon the state of the
undocumented remaining bits which are currently not used, so it might be
preferable to mask them out.

Also, I find it a bit confusing/unintuitive that E_STRICT is not
included with E_ALL.

Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
Re: display_errors stdout not working in a .htaccess file [message #170607 is a reply to message #170603] Tue, 09 November 2010 20:35 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 11/9/2010 2:53 PM, Thomas Mlynarczyk wrote:
> Jerry Stuckle schrieb:
>> But your problem is that php_flag is just that - a flag, on or off.
>> What you need is php_value for error_reporting.
>
> Indeed. But I wonder what PHP will do if a "value" directive is set
> using php_flag? The OP wrote that the local value was 0 and the master
> 30711 (which excludes notices, btw. and would therefore not have shown
> any error in my example script). Could it be that
>
> php_flag error_reporting <non-flag-or-invalid-value>
>
> will have the same effect as
>
> php_value error_reporting 0
>
> instead of raising an error and/or keeping the master value?
>
> Greetings,
> Thomas
>

It will not set it to the correct value. Flag takes true/false on/off
only. Looks like it sets it to false (0)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: display_errors stdout not working in a .htaccess file [message #170608 is a reply to message #170607] Tue, 09 November 2010 21:27 Go to previous messageGo to next message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma: 0
Senior Member
Jerry Stuckle schrieb:

[Using php_flag instead of php_value in .htaccess]
> It will not set it to the correct value. Flag takes true/false on/off
> only. Looks like it sets it to false (0)

Then it seems that this is the cause of the OP's problem. I suppose
php_flag exists only so Apache will "translate" true/false/on/off to
their respective integer values instead of treating them as literal
strings. So "php_flag <directive> on" is basically a kind of syntactic
sugar for "php_value <directive> 1"? And thus we could theoretically do
without php_flag and use php_value for everything and make life simpler?

Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
Re: display_errors stdout not working in a .htaccess file [message #170609 is a reply to message #170608] Tue, 09 November 2010 21:41 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 11/9/2010 4:27 PM, Thomas Mlynarczyk wrote:
> Jerry Stuckle schrieb:
>
> [Using php_flag instead of php_value in .htaccess]
>> It will not set it to the correct value. Flag takes true/false on/off
>> only. Looks like it sets it to false (0)
>
> Then it seems that this is the cause of the OP's problem. I suppose
> php_flag exists only so Apache will "translate" true/false/on/off to
> their respective integer values instead of treating them as literal
> strings. So "php_flag <directive> on" is basically a kind of syntactic
> sugar for "php_value <directive> 1"? And thus we could theoretically do
> without php_flag and use php_value for everything and make life simpler?
>
> Greetings,
> Thomas
>

No, it is a true/false directive, not a value directive. php_flag and
php_value are used for different options.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: display_errors stdout not working in a .htaccess file [message #170610 is a reply to message #170580] Tue, 09 November 2010 23:13 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On 08/11/10 23:46, Jim Wigginton wrote:
> On Nov 8, 5:08 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> On 11/8/2010 4:35 PM, yawnmoth wrote:
>>
>>> I have a .htaccess file that contains only one line:
>>
>>> php_flag display_errors on
>>
>>> Only problem: Errors aren't being displayed as I'd expect. Any ideas
>>> as to why? Is there some setting in httpd.conf that can be used to
>>> prevent errors from displaying?
>>
>> What about error_reporting?
>
> I've tried setting error_reporting with the following:
>
> php_flag error_reporting 30719
> php_flag error_reporting E_ALL

You can't use the constants in .htaccess, you have to use the numeric
values. Also, php_flag is used for booleans. What you want is possibly:

php_value error_reporting 30719

Rgds

Denis McMahon
Re: display_errors stdout not working in a .htaccess file [message #170617 is a reply to message #170605] Wed, 10 November 2010 14:15 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(Thomas Mlynarczyk)

> Michael Fesser schrieb:
>>> [error_reporting]
>> -1 should do to include all.
>
> Correct. But personally I prefer the more explicit E_ALL | E_STRICT.

Same here. In my php.ini it's set like that.

> And, strictly speaking, one should not rely upon the state of the
> undocumented remaining bits which are currently not used, so it might be
> preferable to mask them out.

It's documented in two places:

| […] consider using a larger value to cover all bit fields from now and
| well into the future, a numeric value like 2147483647

And on another page:

| Passing in the value -1 will show every possible error, even when new
| levels and constants are added in future PHP versions.

So I think it's safe to make use of it if necessary, i.e. in an
..htaccess file where you can't use PHP's constants.

> Also, I find it a bit confusing/unintuitive that E_STRICT is not
> included with E_ALL.

IIRC this will be changed in PHP 6.

Micha
Re: display_errors stdout not working in a .htaccess file [message #170622 is a reply to message #170617] Thu, 11 November 2010 18:17 Go to previous message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma: 0
Senior Member
Michael Fesser schrieb:

[Unused bits for error_reporting() levels]
> It's documented in two places:
> | […] consider using a larger value to cover all bit fields from now and
> | well into the future, a numeric value like 2147483647
> And on another page:
> | Passing in the value -1 will show every possible error, even when new
> | levels and constants are added in future PHP versions.

Okay, I had overlooked that. Still, I prefer explicit constants to
"magic numbers".

> So I think it's safe to make use of it if necessary, i.e. in an
> .htaccess file where you can't use PHP's constants.

In such cases, yes.

Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: freelancer looking for web-development projects
Next Topic: ANNOUNCE: NHI1-0.9, PLMK-1.7 und libmsgque-4.7
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 21 19:27:23 GMT 2024

Total time taken to generate the page: 0.02515 seconds