...

View Full Version : including php files with params



Duffman12
11-01-2006, 08:05 PM
so on php.net (http://us2.php.net/manual/en/function.include.php) it says you can include a php and send that php file params by using the full address:


<?php

/* This example assumes that www.example.com is configured to parse .php
* files and not .txt files. Also, 'Works' here means that the variables
* $foo and $bar are available within the included file. */

// Won't work; file.txt wasn't handled by www.example.com as PHP
include 'http://www.example.com/file.txt?foo=1&bar=2';

// Won't work; looks for a file named 'file.php?foo=1&bar=2' on the
// local filesystem.
include 'file.php?foo=1&bar=2';

// Works.
include 'http://www.example.com/file.php?foo=1&bar=2';

$foo = 1;
$bar = 2;
include 'file.txt'; // Works.
include 'file.php'; // Works.

?>

i was wondering if there is another way to include a php with params using relative notation (better practice).
e.g. include 'file.php?foo=1&bar=2';

Fumigator
11-02-2006, 12:50 AM
There's really no need for params like that if the file is in your own file system. You can simply declare the varables before the include statement and they will be available in the included file. Scope restrictions apply, of course.

Duffman12
11-02-2006, 01:20 AM
There's really no need for params like that if the file is in your own file system. You can simply declare the varables before the include statement and they will be available in the included file. Scope restrictions apply, of course.
ohhhh, that's what that last example is of. sweet, thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum