PHP fails silently when php-code is within html tag

Posted by Michal M on Stack Overflow See other posts from Stack Overflow or by Michal M
Published on 2010-06-10T13:02:10Z Indexed on 2010/06/11 9:33 UTC
Read the original article Hit count: 356

Filed under:
|
|

PROBLEM UPDATED, READ BELOW

For some reason my CI fails silently when loading view.
Loading view is simply called from controller

$this->load->view('templates/default.php');

Now. There are some functions in the loaded view that are not defined unless a proper helper is loaded as well. Normally, php would throw an error, but instead it fails silently here. I have no idea why. The template gets outputted till the line containing the undefined function.

It took me long time to realise where my script is failing.

Here's my setup:

  • Windows 7 Ultimate
  • Apache 2.2.15
  • PHP 5.3.2 with following error reporting settings:
    • display_errors = On
    • display_startup_errors = On
    • error_reporting = E_ALL | E_STRICT
  • CodeIgniter 1.7.2

Any ideas why would that be?


UPDATE

After further debugging, it turned out that PHP fails to report any errors when php code is inline with HTML and within the HTML tag. Now this is bizarre.

This returns Fatal Error:

<p><?php echo $bogus(); ?></p>

This doesn't and fails silently:

<p class="<?php echo $bogus(); ?>">paragraph</p>

Why? :O


UPDATE 2

Further investigation showed that if an error_log in PHP is specified, the errors are in fact reported in that file, but still not in the browser... Again, why?


UPDATE 3

Actually my code should be slightly different. Checked another PHP installation on completely different machine and it confirmed the PHP bug. Reported here: http://bugs.php.net/bug.php?id=52040

© Stack Overflow or respective owner

Related posts about php

Related posts about debugging