I am trying to use an include function in my code, but I keep getting an error.
The problem is that I need to also send a URL wrapper.
For instance, the file is 'code.php', but I need it to be invoked as 'code.php?arg=x'
Is there anyway to do this?
I tried to follow the example from here, but it doesn't seem to work.
help using 'include'
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
include() is a filesystem level function.
Those query strings are only parsed when read via a web server so include ('http://localhost/~username/file.php?page=blah');
Those query strings are only parsed when read via a web server so include ('http://localhost/~username/file.php?page=blah');
guess, browser called file is:
index.php?arg_x=whatever
index.php:
test.inc.php:
index.php?arg_x=whatever
index.php:
Code: Select all
<?php
include('test.inc.php');
?>Code: Select all
<?php
if (isset($_GET['arg_x'])) { $arg_x=$_GET['arg_x']; } // You may put this and the next line ...
else { $arg_x=''; } // ... into file index.php also.
if ($arg_x=='whatever')
{
//do something
}
else
{
// do something else
}
?>-
MasterCephus
- Forum Newbie
- Posts: 3
- Joined: Thu Jun 30, 2005 2:49 pm
do what I told you to do.
you can either use the $_GET[] array that is passed from the url or you can set your own above the include:
ex:
you can either use the $_GET[] array that is passed from the url or you can set your own above the include:
ex:
Code: Select all
$_GETї'whatever'] = "e;bob"e;;
include("e;yourpage.php"e;);Code: Select all
echo $_GETї'whatever'];