Connecting Tech Pros Worldwide Forums | Help | Site Map

when does require() not require

Matthew Crouch
Guest
 
Posts: n/a
#1: Dec 1 '05
I'm building a site hosted on Yahoo, and apparently they've got it set
so that nothing -- not even fatal errors -- are displayed.

I also have an extremely complicated line of code:
require_once('../head.inc');

that is failing. works fine on my local copy (PHP5) but not prod server
(4.3.11). Is there something quirky about paths in Yahoo web hosting?

Sean
Guest
 
Posts: n/a
#2: Dec 1 '05

re: when does require() not require


try putting

error_reporting(E_ALL);

at the top of your script.

And if that doesnt work try:

echo 'display_errors = ' . ini_get('display_errors') . "\n"; //which
will tell you if errors are allowed to be displayed.

Matthew Crouch
Guest
 
Posts: n/a
#3: Dec 1 '05

re: when does require() not require


Sean wrote:[color=blue]
> try putting
>
> error_reporting(E_ALL);
>
> at the top of your script.
>
> And if that doesnt work try:
>
> echo 'display_errors = ' . ini_get('display_errors') . "\n"; //which
> will tell you if errors are allowed to be displayed.
>[/color]
yeah, they've got display_errors 'off' and i don't think there's a way
to change it... error_reporting() returns "2039" which isn't even in the
chart.

echo error_reporting();
error_reporting(E_ALL ^ E_NOTICE);
echo error_reporting();

displays 20392039, so I'm not affecting it
Sean
Guest
 
Posts: n/a
#4: Dec 1 '05

re: when does require() not require


Try

$old_value = ini_set('display_errors', 'on');

if ($old_value === false)
print "Nope";
else
print "It worked: old value was $old_value";

Something tells me though its probably not going to work.

Sjoerd
Guest
 
Posts: n/a
#5: Dec 1 '05

re: when does require() not require


You can try:

ini_set("display_errors", "on");

If that does not work, setting an error handler will:

function error_handler($errno, $errstr, $errfile='',
$errline=0, $errcontext=false) {
echo '<p style="font-weight: bold">';
echo $errfile.":".$errline.": ".$errstr;
echo '</p>';
}

set_error_handler('error_handler');

However: "Although display_errors may be set at runtime (with
ini_set()), it won't have any affect if the script has fatal errors."
An error handler will of course also not always work, particularly not
with parse errors.

The good news, you can check for parse errors by running:

php -l filename

Matthew Crouch
Guest
 
Posts: n/a
#6: Dec 1 '05

re: when does require() not require


Sean wrote:[color=blue]
> Try
>
> $old_value = ini_set('display_errors', 'on');
>
> if ($old_value === false)
> print "Nope";
> else
> print "It worked: old value was $old_value";
>
> Something tells me though its probably not going to work.
>[/color]
it says it worked but it didn't, because ini_set returns a string, not a
boolean. the correct comparison ($old_value == false) says "Nope"
Sean
Guest
 
Posts: n/a
#7: Dec 1 '05

re: when does require() not require


Then you are left with php.net/manual/en/function.set-error-handler.php
which Sjoerd already mentioned.

Dikkie Dik
Guest
 
Posts: n/a
#8: Dec 1 '05

re: when does require() not require


Matthew Crouch wrote:[color=blue]
> I'm building a site hosted on Yahoo, and apparently they've got it set
> so that nothing -- not even fatal errors -- are displayed.
>
> I also have an extremely complicated line of code:
> require_once('../head.inc');
>
> that is failing. works fine on my local copy (PHP5) but not prod server
> (4.3.11). Is there something quirky about paths in Yahoo web hosting?[/color]
Is the "requiring" line in another file that is included from another
directory? if so, the line may not select the file you think it selects.

See http://nl3.php.net/manual/en/function.include.php

Best regards
Closed Thread