Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7159745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:16:55+00:00 2026-05-28T13:16:55+00:00

Summary Amazingly I could find nothing about this on Google or SO. When I

  • 0

Summary

Amazingly I could find nothing about this on Google or SO. When I throw an exception in PHP it appears in my console twice, complete with error message and stack trace. The first time it’s printed it says “PHP Fatal error: …” and the second time it just says “Fatal error: …”. I haven’t tested this is the Apache plugin version.

Example

With some namespaces and paths shortened with ‘…’ for safety:

$ php code/com/.../tabular_data.php
PHP Fatal error:  Uncaught exception 'Exception' with message 'File type not supported' in /home/codemonkey/.../tabular_data.php:56
Stack trace:
#0 /home/codemonkey/.../tabular_data.php(88): com\...\Tabular_Data->loadFromFile('/home/codemonke...', false)
#1 /home/codemonkey/.../tabular_data.php(95): com\...\Tabular_Data::fromFile('/home/codemonke...')
#2 {main}
  thrown in /home/codemonkey/.../tabular_data.php on line 56

Fatal error: Uncaught exception 'Exception' with message 'File type not supported' in /home/codemonkey/.../tabular_data.php:56
Stack trace:
#0 /home/codemonkey/.../tabular_data.php(88): com\...\Tabular_Data->loadFromFile('/home/codemonke...', false)
#1 /home/codemonkey/.../tabular_data.php(95): com\...\Tabular_Data::fromFile('/home/codemonke...')
#2 {main}
  thrown in /home/codemonkey/.../tabular_data.php on line 56

Question

I assume it has something to do with stderr and stdout both printing the error. In any case how do I ask PHP nicely to only print it once, preferably to stderr?


Version output

PHP 5.3.9 (cli) (built: Jan 11 2012 17:09:48)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

The code

http://pastebin.com/iBUGJ2eY
This is the exact code that displays double exceptions for me, with namespaces and paths edited to foos. Note that I always get double exceptions in the command line on this installation. I’m all but certain that the issue lies in the PHP configuration.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:16:57+00:00Added an answer on May 28, 2026 at 1:16 pm

    Got it reproduced. The first error message is a result of the log_errors setting and goes to STDERR.

    The second is a result of display_errors and goes to STDOUT.

    Both settings can be altered during runtime. So in order to “ask PHP nicely”, this suffices:

    ini_set('log_errors', 1);
    ini_set('display_errors', 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Summary: How would I go about solving this problem? Hi there, I'm working on
Summary: I want to know if it is possible to do something like this:
SUMMARY: The goal is to find the path to the WEB-INF folder in the
Summary: I have PHP(5.3.8) installed as an Apache Module, and installed APC via PECL.
Summary: I have a struct that is read/written to file. This struct changes frequently,
Summary: the Exception is telling me that the transaction is read-only; a debug println
Summary Hi All, OK, further into my adventures with custom controls... In summary, here
Summary What's the best way to ensure a table cell cannot be less than
SUMMARY: When browsing an ASP.NET website using Windows Explorer, popup windows do not borrow
Summary: I'm developing a persistent Java web application, and I need to make sure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.