Skip to content
Advertisement

Tag: require

require footer and header each page but error 500

Hi, I start in PHP and I create my website. I create a component of header and footer to print on each page with : require ‘/assets/components/header.php’; and require ‘/assets/components/footer.php’; So, the problem is that on localhost, it works, but on website, it didn’t work and i have a http error 500 Repertory : Folder tree I try : 1.

require_once returns true instead of expected object

Both vendor/autoload.php files are basically identical: In both files: This has had me digging into Composer’s autoload files (which has been insightful), but I’m still perplexed: Why does requiring the first file return boolean true, and not object(ComposerAutoloadClassLoader? Update I created a copy of vendor/autoload.php, vendor/aught.php and when I require that one, it returns the object. Answer require_once returns true

register_shutdown_function doesn’t pass variables…?

I’ve run into some difficulties with register_shutdown_function() in PHP. I have a header.php file which contains: $_SESSION contains an array called “user”, containing things like the user ID and their username. I extract $_SESSION simply so I can use $user[“id”] rather than $_SESSION[“user”][“id”]. Then, in footer.php I have this code: to put the info back into the session, in case

Difference between “include” and “require” in php

Is there any difference between them? Is using them a matter of preference? Does using one over the other produce any advantages? Which is better for security? Answer You find the differences explained in the detailed PHP manual on the page of require: require is identical to include except upon failure it will also produce a fatal E_COMPILE_ERROR level error.

Advertisement