Possible Duplicate:
PHP - include a php file and also send query parameters
Because this doesn't work for me:
<?php include ('list-options.php?format=list'); ?>
Possible Duplicate:
PHP - include a php file and also send query parameters
Because this doesn't work for me:
<?php include ('list-options.php?format=list'); ?>
No. You can set a variable and use it in just like it was declared in the file though. Read up here: http://www.php.net/manual/en/function.include.php
<?php
$format = "list";
include("list-options.php");
?>
They don't support it directly but you can emulate it using:
$_GET['format'] = 'list';
include("list-options.php");
The script will think it was called with list-options.php?format=list
.
While you can't add parameters to files included from the local server, you can if your are including a remote file. If you have URL fopen enabled in your PHP.ini, you could do the following:
include('http://www.example.com/script.php?param=1&other=2');
However I think you're just looking to share values between PHP and the included file. The included file will have access to all variables defined in the scope it is included in. So the include in this example would be able to access $a
.
$a = "hello include";
include('local.php');