php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46305 Exception handler not invoked when using -r command line option
Submitted: 2008-10-15 15:42 UTC Modified: 2009-04-21 10:34 UTC
From: jbq at caraldi dot com Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 5CVS-2008-10-24 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
12 + 44 = ?
Subscribe to this entry?

 
 [2008-10-15 15:42 UTC] jbq at caraldi dot com
Description:
------------
When using the "-r" or "-run" command-line option to execute code, a custom exception handler is not invoked.

Reproduce code:
---------------
$ cat command_line_exception_handler.php
<?
function handler($e) {
    print "Caught exception " . $e->getMessage() . "\n";
}
set_exception_handler("handler");
throw new Exception("Hello, World!");


Expected result:
----------------
$ php command_line_exception_handler.php
Caught exception Hello, World!

$ php -r "require 'command_line_exception_handler.php';"
Caught exception Hello, World!

Actual result:
--------------
$ php command_line_exception_handler.php
Caught exception Hello, World!

$ php -r "require 'command_line_exception_handler.php';"

Fatal error: Uncaught exception 'Exception' with message 'Hello, World!' in /home/jbq/command_line_exception_handler.php:6
Stack trace:
#0 Command line code(1): require()
#1 {main}
  thrown in /home/jbq/command_line_exception_handler.php on line 6


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-21 10:34 UTC] jani@php.net
Like said in manual page for CLI: "Note: This option is meant for a very basic stuff." http://php.net/cli

What you're doing isn't basic.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 04:01:30 2024 UTC