How do you pass a parameter into an include file? I tried the following but it doesn't work.
include "myfile.php?var=123";
and in myfile.php, I try to retrieve the parameter using $_GET["var"].
include "myfile.php?var=123";
will not work. PHP searches for a file with this exact name and does not parse the parameter
for that I also did this:
include "http://MyGreatSite.com/myfile.php?var=123";
but it does not also work.
Any hints? Thanks.
Wrap the contents of the included file in a function (or functions). That way you can just do
include "myfile.php";
myFileFunction($var1, $var2);
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