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

Dreamer's avatar

Blank error page after upgrading to PHP 7

Hi

After upgrading my Xampp to PHP 7 i noticed that laravel shows blank error pages. The log still shows errors as normal. Funny thing, if i put a random word into a controller, the error is shown but when i put it into a trait then the error page is blank. Also, other errors in controller are not shown. Only error that is shown (that i have found) is "Parse error: syntax error, unexpected variable (T_VARIABLE)" when i put random word into controller.

How can i fix it?

0 likes
21 replies
d3xt3r's avatar

"Parse error: syntax error, unexpected variable (T_VARIABLE)"

When ? show some code related to your controller, view and the error log.

shez1983's avatar

check your logs? laravel, or xampp. to see what error is being reported and what lines

Dreamer's avatar

@premsaurav @shez1983 The problem is not the errors, but the fact that error pages do not appear. I created errors myself to test if it shows them. My old code, the one i copied from old xampp worked fine. The problem is related to moving project to new xampp installation with PHP 7.

When there is no errors, the page itself displays fine without problems.

d3xt3r's avatar

@Dreamer Lets debug, see if it reaches the handler

// App\Exceptions.php
    public function render($request, Exception $e)
    {
    dd($e);
        return parent::render($request, $e);
    }
1 like
Dreamer's avatar

@premsaurav

Yeah, it works. I saw the error:

FatalThrowableError {#332 ▼
  #message: "Fatal error: Call to undefined function App\Http\Controllers\Module\jdhf()"
  #code: 0
  #file: "C:\xampp\htdocs\app\Http\Controllers\Module\DashboardController.php"
  #line: 29
  #severity: E_ERROR
  -trace: {▶}
}
d3xt3r's avatar

next step ...

public function render($request, Exception $e)
    {
         $response =  parent::render($request, $e);
         dd($response->content()); // to see if content is being set
    }
1 like
d3xt3r's avatar

last step ... (conditional)

 public function render($request, Exception $e)
    {
        $response =  parent::render($request, $e);
        $response->setStatusCode(200);
        return $response;
    }

If it shows now, then it has nothing to do with laravel, may be some php 7 / xammp setting. Will try to figure out and let you know in that case.

1 like
Dreamer's avatar

@premsaurav

Thanks for your time. Yes, it shows the error page. What it could be related to? I could google it... but right now i have no idea how to begin searching.

One thing to note here too. If i open source of the blank error page, it shows very basic html... like, html, head, body tags only.

d3xt3r's avatar

@Dreamer Really don't have much idea as of now, may could play around with the status codes and check where you stop seeing the response. This might help to pinpoint some strange behavior.

d3xt3r's avatar

@Dreamer No worries, checking now, meanwhile, few details, which os (permission issues if any ?)

Dreamer's avatar

@premsaurav Thank you!

I am using Windows 10, downloaded latest Xampp yesterday. Also, just in case, i made a new laravel project and checked if it has the same problem. Yes, the problem was on new project too.

Since i am in Windows there cant be any file permission errors...?

I could also, just in case, reinstall xampp, if that could help.

Oh, and if this makes any difference, i am using virtual host to display my project, but, the new test project i accessed without virtual host and they both had the same problem. So, i doubt that is what causes it.

(Tested clean xampp install it did not help)

d3xt3r's avatar

Hey, tried this on mac works fine, yet to try on windows with PHP 7.

shez1983's avatar

why dont you try homestead or vagrant? or try WAMP instead of XAMP?

lostdreamer_nl's avatar

I just ran into a similar issue, in PHP7 they have replaced the Fatal Errors with Exceptions of type Error: http://php.net/manual/en/language.errors.php7.php

This gave us a couple of uncatchable exceptions in the exception handler, you might want to test by removing the typehints in the error handler and check what is being written to the logs

lostdreamer_nl's avatar

in app/Exceptions/Handler.php, remove the typehints

    public function report(Exception $e)
    {
        parent::report($e);
    }
    public function render($request, Exception $e)
    {
        return parent::render($request, $e);
    }

Becomes

    public function report($e)
    {
        parent::report($e);
    }
    public function render($request, $e)
    {
        return parent::render($request, $e);
    }

Removing the 'Exception' typehint will let the FatalErrors be caught as well (they do not extend the Exception class) showing you the actual errors

Good luck

1 like

Please or to participate in this conversation.