I want to use query strings into include function, like include('where.php?id=1'); and echo $_REQUEST in where.php; but gives error.

Warning: include(where.php?id=1) [function.include]: failed to open stream: No error in C:\xampp\htdocs\3g\include.php on line 2

Warning: include() [function.include]: Failed opening 'where.php?id=1' for inclusion (include_path='.;\xampp\php\PEAR') in C:\xampp\htdocs\3g\include.php on line 2

If yes, then how?
If not, then alternate solution.

Recommended Answers

All 3 Replies

I think no way to add query string in include. for what purpose you need like this?

It is possible, if URL fopen wrappers are enabled. But you must specify a full URL. See the manual for details.

commented: Useful post +5

I believe passing a query string to the included file is functionally unneccessary

the included file becomes part of the outer/wrapper/including/calling file //you choose an appropriate description
all the values known to the outer file are known to the included file

if id is given in a query string to the outer file, the value is available to the included file as $_request
if $id is calculated in the outer file, the value of $id is available to the included file as $id

<?php // Outer.php
include(where.php); ?>
<? //where.php
if isset($_request['id']) {echo $_request['id'];} ?>

outer.php?id=wassup_dude outputs to the screen

wassup_dude

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.