I am trying to add some variables at the end of an "include". Is this possible?
Here is the code that DOES NOT WORK:
include('login.php?' . "message=used");
You don't need to include a querystring. Includes/requires essentially put the included code in place. Just declare whatever variables the includes needs before you include the file:
$message = 'used';
include('login.php);
No it's not, and you really have no reason to do so, you see. Every variable you define before the include will be available from the include.
$var = "Hello include";
include("login.php");
//Include.php
echo $var;
Will output "Hello include"
No, the include()
takes the parameter as a filename, so when you use login.php?message=used
it's looking for login.php?message=used.php
, which obviously doesn't exist.
You could alter the .ini
file setting allow_url_include
but this poses a potential security issue, but otherwise just declare your variables before including the file.