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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jbq at caraldi dot com
New email:
PHP Version: OS:

 

 [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: Fri Apr 19 07:01:27 2024 UTC