PHP Require and Include GET

NoodleOfDeath picture NoodleOfDeath · Apr 24, 2011 · Viewed 13.8k times · Source

I would like to require a file but also pass GET variables through the url, but when I write:

<?php
   require_once("myfile.php?name=savagewood");
?>

I get a fatal error. How would I accomplish this functionality in a different way, such that I don't get a fatal error?

Answer

Shakti Singh picture Shakti Singh · Apr 24, 2011

variables will be available as normal you do not have to pass like this.

$name='savagewood';
require_once("myfile.php");

$name will be available in myfile.php