Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. option 'explicit' for php

option 'explicit' for php

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
c++phpsysadminquestionlounge
7 Posts 4 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jeffrey Webster
    wrote on last edited by
    #1

    Hi, I'm having major problems with erratic php behavior. I think it's something to do with the server, though I'm not sure. It is incomprehensible in a way that C++ or VB could never be: the same code will work and then not work even though no inputs or context have changed. I need to get a handle on this. A step in the right direction would be to get more information out of the server. Is there an "explicit" or "strict" option in php? I've searched for it here, and on the general Internet and haven't found it. I could try to explain the behavior but no one would believe me anyway. It is pretty much as if there were a "ghost in the machine" making arbitrary decisions as to when the code will work. Jeff

    F M V 3 Replies Last reply
    0
    • J Jeffrey Webster

      Hi, I'm having major problems with erratic php behavior. I think it's something to do with the server, though I'm not sure. It is incomprehensible in a way that C++ or VB could never be: the same code will work and then not work even though no inputs or context have changed. I need to get a handle on this. A step in the right direction would be to get more information out of the server. Is there an "explicit" or "strict" option in php? I've searched for it here, and on the general Internet and haven't found it. I could try to explain the behavior but no one would believe me anyway. It is pretty much as if there were a "ghost in the machine" making arbitrary decisions as to when the code will work. Jeff

      F Offline
      F Offline
      fly904
      wrote on last edited by
      #2

      This is a pretty vague problem. Could you not find any help here[^]?

      If at first you don't succeed, you're not Chuck Norris.

      1 Reply Last reply
      0
      • J Jeffrey Webster

        Hi, I'm having major problems with erratic php behavior. I think it's something to do with the server, though I'm not sure. It is incomprehensible in a way that C++ or VB could never be: the same code will work and then not work even though no inputs or context have changed. I need to get a handle on this. A step in the right direction would be to get more information out of the server. Is there an "explicit" or "strict" option in php? I've searched for it here, and on the general Internet and haven't found it. I could try to explain the behavior but no one would believe me anyway. It is pretty much as if there were a "ghost in the machine" making arbitrary decisions as to when the code will work. Jeff

        M Offline
        M Offline
        Marc Firth
        wrote on last edited by
        #3

        Jeffrey Webster wrote: erratic php behavior PHP itself is generally not erratic and pretty straight forward in the way it parses code. You code either works or PHP tells you that it doesn't. You can however, increase decrease what error messages you receieve. Add one of the following Code to each Page you test / include in a config file. To display all errors except for notices: <?php ini_set('display_errors', 1); error_reporting(E_ALL ^ E_NOTICE); ?> To display all errors including notices: <?php ini_set('display_errors', 1); error_reporting(E_ALL); ?> (I think that's the right way round)

        Portfolio | Web Design, Web Hosting & IT Support

        J 1 Reply Last reply
        0
        • M Marc Firth

          Jeffrey Webster wrote: erratic php behavior PHP itself is generally not erratic and pretty straight forward in the way it parses code. You code either works or PHP tells you that it doesn't. You can however, increase decrease what error messages you receieve. Add one of the following Code to each Page you test / include in a config file. To display all errors except for notices: <?php ini_set('display_errors', 1); error_reporting(E_ALL ^ E_NOTICE); ?> To display all errors including notices: <?php ini_set('display_errors', 1); error_reporting(E_ALL); ?> (I think that's the right way round)

          Portfolio | Web Design, Web Hosting & IT Support

          J Offline
          J Offline
          Jeffrey Webster
          wrote on last edited by
          #4

          Hi, Thanks for your reply and the code. I'm sorry but I didn't quite understand this: "Add one of the following Code to each Page you test / include in a config file." Should I create a php file (say, error_display.php) with the cited code and then include it at the top of each php page? Or should I be editing the php config file directly? Thanks for any clarification:). Jeff

          F M 2 Replies Last reply
          0
          • J Jeffrey Webster

            Hi, Thanks for your reply and the code. I'm sorry but I didn't quite understand this: "Add one of the following Code to each Page you test / include in a config file." Should I create a php file (say, error_display.php) with the cited code and then include it at the top of each php page? Or should I be editing the php config file directly? Thanks for any clarification:). Jeff

            F Offline
            F Offline
            fly904
            wrote on last edited by
            #5

            Jeffrey Webster wrote:

            Or should I be editing the php config file directly?

            Edit the 'error_reporting' line (or add it) to your php.ini file to look like the following:

            error_reporting = E_ALL

            Then restart your web server. I would suggest creating your own custom error handler. The following example simply logs the error into a file storing what file the error occurred, what line it happened, the message given and dumps the variables currently stored in the symbol table.

            <?php

            // This function will be called for every error that occurs
            function errorHandler($type, $message, $file, $line, $symboltable)
            {

            // Log all errors in a file (New line at the end is deliberate)
            error\_log('ERROR in ' . $file . ' on line ' . $line . ' - ' . $message . ' \[var dump\] ' . print\_r($symboltable, true) . '
            

            ', 3, 'errors.log');

            // If fatal error, die() as there is no use to carry on.
            if ($type == E\_USER\_ERROR)
            {
            	die( $message );
            }
            
            // Alert the user that an error has occurred.
            echo 'An error has occurred, sorry for the inconvenience.';
            
            // Return true so that it doesn't execute the internal PHP error handler.
            return true;
            

            }

            // Report all errors. Unnecessary if it is enabled in the php.ini.
            error_reporting(E_ALL);

            // Define custom handler.
            set_error_handler('errorHandler');

            ?>

            More options of what you can do the error_log() function can do, such as email, write to the system logger etc., can be found in the documentation[^].

            If at first you don't succeed, you're not Chuck Norris.

            1 Reply Last reply
            0
            • J Jeffrey Webster

              Hi, Thanks for your reply and the code. I'm sorry but I didn't quite understand this: "Add one of the following Code to each Page you test / include in a config file." Should I create a php file (say, error_display.php) with the cited code and then include it at the top of each php page? Or should I be editing the php config file directly? Thanks for any clarification:). Jeff

              M Offline
              M Offline
              Marc Firth
              wrote on last edited by
              #6

              Jeffrey Webster wrote: Should I create a php file (say, error_display.php) with the cited code and then include it at the top of each php page? Or should I be editing the php config file directly? Either. 1)Create a php file (say, error_display.php) with the cited code and then include it at the top of each php page. or 2) Use fly904's method. Custom error handler is better, but to start you should probably just get them showing up on the page you are working on.

              Portfolio | Web Design, Web Hosting & IT Support

              1 Reply Last reply
              0
              • J Jeffrey Webster

                Hi, I'm having major problems with erratic php behavior. I think it's something to do with the server, though I'm not sure. It is incomprehensible in a way that C++ or VB could never be: the same code will work and then not work even though no inputs or context have changed. I need to get a handle on this. A step in the right direction would be to get more information out of the server. Is there an "explicit" or "strict" option in php? I've searched for it here, and on the general Internet and haven't found it. I could try to explain the behavior but no one would believe me anyway. It is pretty much as if there were a "ghost in the machine" making arbitrary decisions as to when the code will work. Jeff

                V Offline
                V Offline
                Vasudevan Deepak Kumar
                wrote on last edited by
                #7

                Check this out: http://www.faqts.com/knowledge_base/view.phtml/aid/651/fid/38[^]

                Vasudevan Deepak Kumar Personal Homepage
                Tech Gossips
                The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep!

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups