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?
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
<?php
$getVarsArray = $_GET;
$postVarsArray = $_POST;
/* n number of variables and lines of code*/
include('script-a.php');
?>
Now in script-a.php has access to $getVarsArray
and $postVarsArray
and if in any case you are in doubt you can use $GLOBALS
to access any variable throughout the life cycle of a script. But using global variables is a sin. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With