I have a weird error in my php code. I'm using spl_autoload_register this way:
function load($class) {
require 'class/' . $class . '.php';
}
spl_autoload_register('load');
Then on my page, when I try loading a class, the whole page is loaded again. This is what I write:
<?php include('inc/header.php'); ?>
<body>
<?php include('inc/nav.php'); ?>
[some html]
<?php load('Class'); ?>
[otherhtml]
<?php include('inc/footer.php') ?>
But when I try running it on my local server (using xampp), the whole page is included again, and it looks like this:
[header]
<body>
[nav]
[some html]
[header]
<body>
[nav]
[some html]
[other html]
[footer]
[other html]
[footer]
And I get a few php errors, mostly due to the fact that the header is included twice:
A session had already been started - ignoring session_start().
And
Fatal error: Cannot redeclare load() (previously declared in C:...inc\header.php:2) in C:...inc\header.php on line 4
This only happens when running on xampp. I uploaded everything to my webserver, and there is no problem. It was working fine two days ago, and might have started when I tried installing composer using phpstorm.
Any help would be appreciated. Thanks !