Re: [PHP] Backtrace in fatal error?

2010-09-01 Thread freeman3
Thanks!
I didn't notice the register_shutdown_function function.
But it executes always I want to run it only to track fatal error. Also I 
can't get the backtrace properly:( I can't use 5.3 so I guess it works 
differently in 5.2

Richard Quadling wrote:

> On 31 August 2010 09:49, Paul Freeman  wrote:
>> When fatal error occurs is it possible to output also the backtrace in
>> the error log? The simple error message with file line only is quite
>> useless...
> 
>  namespace baz;
> 
> set_error_handler(
> function($ErrNo, $ErrStr, $ErrFile, $ErrLine, $ErrContext){
> echo 'An error occurred.', PHP_EOL;
> var_export(debug_backtrace(true));
> 
> // Allow PHP to continue executing.
> return false;
> },
> -1
> );
> 
> register_shutdown_function(
> function(){
> echo 'We died a terrible death.';
> var_export(debug_backtrace(true));
> }
> );
> 
> function bar() {
> echo 'In ', __FUNCTION__, PHP_EOL;
> echo 1 / 0; // Divide by zero warning.
> foo();
> }
> 
> function foo() {
> echo 'In ', __FUNCTION__, PHP_EOL;
> $a = \SNAFU; // Fatal error
> }
> 
> bar();
> ?>
> outputs ...
> 
> In baz\bar
> An error occurred.
> array (
>   0 =>
>   array (
> 'file' => 'Z:\\bad.php',
> 'line' => 24,
> 'function' => 'baz\\{closure}',
> 'args' =>
> array (
>   0 => 2,
>   1 => 'Division by zero',
>   2 => 'Z:\\bad.php',
>   3 => 24,
>   4 =>
>   array (
>   ),
> ),
>   ),
>   1 =>
>   array (
> 'file' => 'Z:\\bad.php',
> 'line' => 33,
> 'function' => 'baz\\bar',
> 'args' =>
> array (
> ),
>   ),
> )
> Warning: Division by zero in Z:\bad.php on line 24
> In baz\foo
> 
> Fatal error: Undefined constant 'SNAFU' in Z:\bad.php on line 30
> We died a terrible death.array (
>   0 =>
>   array (
> 'function' => 'baz\\{closure}',
> 'args' =>
> array (
> ),
>   ),
> )
> 
> So, it looks like extension or a core mod only.
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: require_once

2010-09-01 Thread freeman3
I think the files included just when you call it to include. How do you mean 
it later?
What's in that file? A class or direct code?

David Mehler wrote:

> Hello,
> I've got probably a simple question on require_once. I've got a file
> that has require_once at the top of it pulling in another file of
> functions. Later on in this file I've got another require_once
> bringing in a second file. In this second file I have a function call
> to a function defined in the first files' top require_once functions
> file. I'm getting a call to undefined function.
> Should I change he require_once to require at the top of the first
> file to fix? I thought require_once meant it was in that file and
> anything pulled in later?
> Thanks.
> Dave.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: error_log file error reporting level

2010-09-01 Thread freeman3
I don't know that too.
I think the solution is to use your own error handler and save error in some 
another file.

hovnocuc wrote:

> Hello,
> 
> [ Question ]
> How do I force error_log to log only errors specified in the
> error_reporting directive? Is it even possible or did I get something
> wrong? I have one old script which uses ereg and the awesome size of the
> error log is getting on my nerves.
> 
> [ Current ini config ]
> error_reporting = E_ALL & ~E_DEPRECATED  ;;or E_ALL ^ E_DEPRECATED
> display_errors = Off
> log_errors = On
> error_log = /var/log/php-fpm/php-errors.log
> 
> [ PHP ]
> 5.3.3 + suhosin patch 5.3.3-0.9.10 + suhosin extension 0.9.32.1
> pecl: imagick-3.0.1RC1, APC-3.1.3p1, geoip-1.0.7, rar-2.0.0
> php configure: in the appendix
> 
> [ Expected result ]
> php-errors.log containing all errors EXCEPT deprecated notices
> 
> [ Actual result ]
> 
>  PHP Deprecated:  Function ereg() is deprecated in ...
> 
> 
> [ Notes ]
> I know which ini php loads, so yeah.. I'm actually using the same that
> I'm configuring.
> I'm not using syslog, but a file. See Current ini config above.
> 
> 
> Thank you for your time.
> 
> [ Appendix ]
> ../configure --prefix=/usr --enable-fpm --disable-rpath --with-pear
> --disable-debug --with-openssl --with-pcre-regex --with-zlib
> --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-exif
> --enable-inline-optimization --with-gd --with-jpeg-dir --with-png-dir
> --with-freetype-dir --with-gettext --with-imap --with-imap-ssl
> --with-kerberos --enable-mbstring --enable-mbregex --with-mcrypt
> --with-mysql --with-mysqli --enable-pdo --with-pdo-mysql
> --with-pdo-pgsql --with-pgsql --enable-shmop --enable-soap
> --enable-sockets --enable-sqlite-utf8 --enable-sysvmsg --enable-sysvsem
> --enable-sysvshm --with-tidy --enable-wddx --with-xmlrpc --with-xsl
> --enable-zip --enable-ftp --enable-dom --enable-xmlwriter
> --enable-xmlreader --enable-tokenizer --enable-simplexml
> --enable-session --enable-posix --enable-phar --enable-libxml
> --enable-json --with-iconv --enable-filter --enable-fileinfo
> --enable-ctype


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php