error-reporting

PHP 5.4: disable warning “Creating default object from empty value”

僤鯓⒐⒋嵵緔 提交于 2019-11-28 10:03:15
I want to migrate code from PHP 5.2 to 5.4. This worked fine so far except that all the code I use makes extensive use of just using an object with a member without any initialisation, like: $MyObject->MyMember = "Hello"; which results in the warning: "Creating default object from empty value" I know that the solution would be to use: $MyObject = new stdClass(); $MyObject->MyMember = "Hello"; but it would be A LOT OF WORK to change this in all my code, because I use this many times in different projects. I know, it's not good style, but unfortunately I'm not able to spend the next weeks adding

How can I stop PHP notices from appearing in wordpress?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 06:20:01
I know about error_reporting(0); , and ini_set('display_errors', false); , but there is a notice appearing in wordpress: Notice: Array to string conversion in /var/www/vhosts/treethink.net/subdomains/parkridge/httpdocs/wp-includes/formatting.php on line 359 it only appears in wordpress, not in any other pages of the site. I checked phpinfo() , and everything is set so that errors are not displayed. Why does this one still show up? Here is the line that generates the error: function wp_check_invalid_utf8( $string, $strip = false ) { $string = (string) $string; I did change some thing in

Parse errors are not displayed

无人久伴 提交于 2019-11-28 02:31:26
问题 I want PHP to display parse errors on screen. What I get instead is a blank page. Nothing gets written to server's error log file. My setup: PHP5.2.9/ IIS 6 (not Apache!). My PHP.INI: error_reporting=E_STRICT display_errors = On display_startup_errors = On log_errors = On error_log = "C:\Program Files\Zend\ZendServer\logs\php_error.log" How do I get parse or fatal errors to be either logged or shown on screen? Thanks, Temuri UPDATE : After playing with different switches it looks to be an IIS

How to find a reason when mkdir fails from PHP?

我怕爱的太早我们不能终老 提交于 2019-11-27 22:51:29
PHP's mkdir function only returns true and false. Problem is when it returns false. If I'm running with error reporting enabled, I see the error message on the screen. I can also see the error message in the Apache log. But I'd like to grab the text of the message and do something else with it (ex. send to myself via IM). How do I get the error text? Update: Following Ayman's idea, I came to this: function error_handler($errno, $errstr) { global $last_error; $last_error = $errstr; } set_error_handler('error_handler'); if (!mkdir('/somedir')) echo "MKDIR failed, reason: $last_error\n"; restore

What is the recommended error_reporting() setting for development? What about E_STRICT?

与世无争的帅哥 提交于 2019-11-27 22:42:31
Typically I use E_ALL to see anything that PHP might say about my code to try and improve it. I just noticed a error constant E_STRICT , but have never used or heard about it, is this a good setting to use for development? The manual says: Run-time notices. Enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code. So I'm wondering if I'm using the best error_reporting level with E_ALL or would that along with E_STRICT be the best? Or is there any other combination I've yet to learn? Jim In PHP 5, the things covered by E

Error logging in C#

依然范特西╮ 提交于 2019-11-27 16:47:56
I am making my switch from coding in C++ to C#. I need to replace my C++ error logging/reporting macro system with something similar in C#. In my C++ source I can write LOGERR("Some error"); or LOGERR("Error with inputs %s and %d", stringvar, intvar); The macro & supporting library code then passes the (possibly varargs) formatted message into a database along with the source file, source line, user name, and time. The same data is also stuffed into a data structure for later reporting to the user. Does anybody have C# code snippets or pointers to examples that do this basic error reporting

Why is exception handling bad?

心不动则不痛 提交于 2019-11-27 16:47:48
Google's Go language has no exceptions as a design choice, and Linus of Linux fame has called exceptions crap. Why? asveikau Exceptions make it really easy to write code where an exception being thrown will break invariants and leave objects in an inconsistent state. They essentially force you to remember that most every statement you make can potentially throw, and handle that correctly. Doing so can be tricky and counter-intuitive. Consider something like this as a simple example: class Frobber { int m_NumberOfFrobs; FrobManager m_FrobManager; public: void Frob() { m_NumberOfFrobs++; m

PHP Error Reporting Production vs Development

六月ゝ 毕业季﹏ 提交于 2019-11-27 07:00:33
问题 What is best practice when setting error reporting on development and production applications? At the moment I have the following: // development error_reporting(E_ALL); // production ini_set('display_errors', 0); ini_set('log_errors', 1); error_reporting(E_ERROR | E_WARNING | E_PARSE); I see people have downvoted the question. Perhaps explain why the question is bad instead of just downvoting. 回答1: Quoting the php-production.ini that should have come bundled with your PHP: ; PHP comes

Why is exception handling bad?

♀尐吖头ヾ 提交于 2019-11-27 04:09:53
问题 Google's Go language has no exceptions as a design choice, and Linus of Linux fame has called exceptions crap. Why? 回答1: Exceptions make it really easy to write code where an exception being thrown will break invariants and leave objects in an inconsistent state. They essentially force you to remember that most every statement you make can potentially throw, and handle that correctly. Doing so can be tricky and counter-intuitive. Consider something like this as a simple example: class Frobber

Error logging in C#

南笙酒味 提交于 2019-11-26 22:29:32
问题 I am making my switch from coding in C++ to C#. I need to replace my C++ error logging/reporting macro system with something similar in C#. In my C++ source I can write LOGERR("Some error"); or LOGERR("Error with inputs %s and %d", stringvar, intvar); The macro & supporting library code then passes the (possibly varargs) formatted message into a database along with the source file, source line, user name, and time. The same data is also stuffed into a data structure for later reporting to the