when does require() not require

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew Crouch

    when does require() not require

    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

    #2
    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('displa y_errors') . "\n"; //which
    will tell you if errors are allowed to be displayed.

    Comment

    • Matthew Crouch

      #3
      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('displa y_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

      Comment

      • Sean

        #4
        Re: when does require() not require

        Try

        $old_value = ini_set('displa y_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.

        Comment

        • Sjoerd

          #5
          Re: when does require() not require

          You can try:

          ini_set("displa y_errors", "on");

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

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

          set_error_handl er('error_handl er');

          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

          Comment

          • Matthew Crouch

            #6
            Re: when does require() not require

            Sean wrote:[color=blue]
            > Try
            >
            > $old_value = ini_set('displa y_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"

            Comment

            • Sean

              #7
              Re: when does require() not require

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

              Comment

              • Dikkie Dik

                #8
                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

                Comment

                Working...