Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

NathanIsaac's avatar

Strange PHP 5.5 View Error

I want to update my Laravel app to use PHP 5.5, however, I came across an update stopping error.

Note: I am using Laravel 4.2.17 and PHP 5.5.22 on Windows 8.1 hosted by IIS.

This code will cause the error.


// route.php
Route::get('/', function()
{
    return View::make('error');
});

// view/error.php

$array = '';

foreach($array as $string)
{
    echo $string;
}

dd('done');

In PHP 5.4 this will return an error ErrorException (E_UNKNOWN) Invalid argument supplied for foreach() which it should. But, in PHP 5.5 it will timeout php. It doesn't even return a helpful error log message. This has also been know to blue screen my machine with a memory error.


Route::get('/', function()
{
    $array = '';

    foreach($array as $string)
    {
        echo $string;
    }

    dd('done');
});

When the code above is run on PHP 5.5 it does return the same error message as it did in PHP 5.4. So what is the difference between running to code in a view vs a route closure?

Any thoughts on why this is the case?

Edit

I was able to find where to code breaks.

Illuminate\View\EnginesPhpEngine on line 37.


protected function evaluatePath($__path, $__data)
    {
        $obLevel = ob_get_level();

        ob_start();

        extract($__data);

        // We'll evaluate the contents of the view inside a try/catch block so we can
        // flush out any stray output that might get out before an error occurs or
        // an exception is thrown. This prevents any partial views from leaking.
        try
        {
            include $__path; // BREAKS RIGHT HERE!!
        }
        catch (\Exception $e)
        {
            $this->handleViewException($e, $obLevel);
        }

        return ltrim(ob_get_clean());
    }
0 likes
1 reply
bashy's avatar

This has also been know to blue screen my machine with a memory error.

Sounds like your PHP install is messed or buggy. I would reinstall ASAP. Either to PHP5.6 or a fresh install of your 5.5 one.

Please or to participate in this conversation.