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 8022849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:23:25+00:00 2026-06-04T22:23:25+00:00

I was working on this book and I found an unexpected situation. When working

  • 0

I was working on this book and I found an unexpected situation.

When working in a PHP/HTML hybrid file, the book says, if I use PHP try/catch without the ob buffer thing, and if there’s an error somewhere in the middle of the file, the PHP engine won’t be able to reach the catch{} line since some output has already been sent to the browser. The book then says this situation could be fixed by using ob_start(), ob_end_clean() and ob_end_flush()

However, when I was playing with the book’s sample code, the try/catch worked just fine without the ob buffer stuff. By saying just fine I mean if there’s an exception the catch{} line could be reached and executed without a problem.

I used a Linode VPS for testing, the PHP version is 5.3.2. I set up the VPS with some ordinary Linode script.

Why is that? 🙂

  • 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-06-04T22:23:26+00:00Added an answer on June 4, 2026 at 10:23 pm

    That statement is nonsense. PHP’s try..catch works just as you would expect, regardless of output that has or hasn’t already been sent to the browser.

    Seeing that even the errata to that book contains errors, I’d say it’s simply not a very good book and am not surprised at all that it contains wrong statements. Just a very quick glance reveals:

    In step 4, the third line of code should read as follows:

    if ($_POST && isset($missing) && !empty($missing)) {
    

    No, it should actually read:

    if ($_POST && !empty($missing)) {
    

    or

    if ($_POST && $missing) {
    

    The author apparently does not understand how to use empty.

    Further:

    An opening curly brace is missing at the end of line 4 of the code in step 2. It should read:

    if (!@include('includes/connection.inc.php')) {
    

    That reeks of bad practices and should be rewritten to:

    if (!file_exists('includes/connection.inc.php')) {
    

    or:

    require_once 'includes/connection.inc.php';
    

    I’m sure there’s more… 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on the following problem from this book . A certain
I am working through Beginning iPhone Development . In the book is this method:
I'm working on a SQL Server 2008 database. This database has two tables. Book
I'm working through a MVC book which uses the older version of Html.RenderAction .
I am tired of working this out myself , i cannot understand the way
i am new in programming under linux and trying to get working this code:
I'm a LAMP guy and ended up working this small news module for an
I do not get the last version of node-http-proxy working (this used to work
I this working Ruby code that i want to make an executable from with
Had this working; at one stage. The problem is the following text is now

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.