DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 26th October 2010
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,080
Thanked 198 Times in 156 Posts
Default PHP displays no output what-so-ever on some errors.

Note: This discussion was originally in "Funny stuff" and moved to a new thread.

I don't think I've ever seen a simple string been put that awkwardly as that. I find it hard to believe it's possible.

Worst thing is, PHP errors suck.

Code:
$isengard->Template($vars;)
The semi-colon is in the wrong place. Oops.
PHP will just exit. No error whatever-so-ever. including from the commandline (Just exits with status 255).

I refactored 300 lines of code. Spot the error ... fun fun fun
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #2   (View Single Post)  
Old 26th October 2010
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

For the most part, PHP is very configurable about warnings and errors, or at least the FastCGI and mod_php setups respect that part of php.ini. You should be able to set it to something that will help you out.

The real problem is that between production-style settings and "I don't fucking care" developers, that in actual practice PHP is more like do anything you can to avoid dieing, even if that means doing something stupid. I have also known people to test on "Live" sites and turn off warnings on development machines. The responses from users are sometimes comical.

PHP is why I like the strongest possible type checking at compile and runtime, and why PHP would be my last choice of dynamic language for anything but a cheap web host or needing a PHP-based third party web app.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #3   (View Single Post)  
Old 26th October 2010
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,080
Thanked 198 Times in 156 Posts
Default

Quote:
For the most part, PHP is very configurable about warnings and errors, or at least the FastCGI and mod_php setups respect that part of php.ini. You should be able to set it to something that will help you out.
Code:
[~]% cat test.php 
<?php
        error_reporting(E_ALL);
        print php_info(;);
?>
[~]% php test.php
Exit 255
error_reporting is already at E_ALL in php.ini, but never hurts to set it twice. display_startup_errors is set to on.

If you have more info, please share. You would do me a huge favor.

Other then this, yeah, it works pretty well. The default messages kind of suck (No backtrace), but as you mentioned that can be configured quite easily.
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #4   (View Single Post)  
Old 28th October 2010
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

Assuming you're lucky enough to be using PHP 5, you might want to append E_STRICT, which isn't included with E_ALL. YMMV with it however, and expressly with the nature of the codebase you're using. Note that PHP's E_STRICT is not quite the same as Perls use strict.

Good PHP code should be E_ALL and E_STRICT compliant, documented, and well covered by unit tests and the like. Don't underestimate the utility of good unit tests.

I assume you know all the stuff about controlling where it sends errors; so you ought to be able to judge what's most convenient for you.


Quote:
Originally Posted by Carpetsmoker View Post
If you have more info, please share. You would do me a huge favor.
Yeah, don't use PHP. I doubt I can do you that favour though :-(.


I might also add that the PHP chatter isn't quite on topic, hardy har haarr
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #5   (View Single Post)  
Old 28th October 2010
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,080
Thanked 198 Times in 156 Posts
Default

Doesn't E_ALL include E_STRICT? I always thought E_ALL was *all* messages ...
In any case, I tried `E_ALL | E_STRICT' and I got the same effect.

From what I remember from PHP4, I never had this sort of problems ... I haven't done a lot of PHP programming for some time until I got landed in this job, in that time either something changed with PHP or something changed with my typing accuracy

And yeah, I used error_handler() and set a custom error handler to just quit on *any* error.
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #6   (View Single Post)  
Old 5th November 2010
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

Quote:
Originally Posted by Carpetsmoker View Post
Doesn't E_ALL include E_STRICT? I always thought E_ALL was *all* messages ...
I checked the manual page before posting, to be sure .


That does say something about the nature of PHP though, doesn't it?
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #7   (View Single Post)  
Old 5th November 2010
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,080
Thanked 198 Times in 156 Posts
Default

Quote:
Originally Posted by TerryP View Post
I checked the manual page before posting, to be sure .

That does say something about the nature of PHP though, doesn't it?
Yeah, it seem E_STRICT was added in PHP 5.3 for some stricter checking ...

XDebug seems interesting (Haven't tried it yet):
http://www.xdebug.org/index.php
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #8   (View Single Post)  
Old 5th November 2010
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,080
Thanked 198 Times in 156 Posts
Default

Ok, so I had some time to test stuff.

One typo consistently reproduces this error:

Code:
<?php
        error_reporting(E_ALL | E_STRICT);

        date(;)
?>
Today I tested this at my FreeBSD machine at home and I *did* get an error there as you would expect!

I compared the php.ini configuration files with the one used at the Fedora core machine I have at work, and they are almost exactly the same ... :-/

I'll do some testing with enabling/disabling extensions later (After-hours, since this is a production machine) ...
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #9   (View Single Post)  
Old 9th November 2010
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,080
Thanked 198 Times in 156 Posts
Default

The default error_reporting was set to:
Code:
error_reporting = E_ALL & E_NOTICE & E_DEPRECATED
Changing this to
Code:
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
Obviously the first one is not right, I overlooked the missing tildes in my earlier examinations of php.ini But as far as I understand it it should still work?

I also don't quite understand why the error_reporting() function doesn't work ...
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
Old 9th November 2010
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

I would've just wrote it as
Code:
E_ALL ^ E_NOTICE ^ E_DEPRECATED
but to each eyes their own readability.


Why do you want notice and deprecated off? (E_ALL = 111011111111111; E_ALL & ~E_NOTICE & ~E_DEPRECATED = 101011111110111)
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
output to a file in java c0mrade Programming 4 15th October 2009 07:55 AM
dwm status bar won't display apm output asemisldkfj General software and network 6 16th August 2009 11:07 PM
strange dmesg output gosha OpenBSD General 4 11th March 2009 01:10 PM
Digital sound output Zodox FreeBSD General 5 12th November 2008 02:21 PM
daemonforums's font displays horribly in firefox s2scott Feedback and Suggestions 15 8th May 2008 01:18 AM


All times are GMT. The time now is 10:06 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick