Log in

View Full Version : passing variables in a PHP include



alankeys
11-08-2016, 07:48 PM
I have called a php include as follows but it doesnt seem to work...

<?php
include '../cms/blog.php?id=41234';
?>

quite confused because the link within a href works fine... eg

<a href="www.site,com/cms40/blog.php?id=41234">article</a>

Can someone put me right ... Cheers

i tried to use $_GET['id']=

but no success..
any help appreciated.

Beverleyh
11-08-2016, 08:51 PM
Try include ('../cms/blog.php?id=41234'); with the parentheses.

DyDr
11-08-2016, 08:57 PM
An include/require statement reads the file through the file system (unless you specify a url using a protocol wrapper like http:// or ftp://). In this case, there are no $_GET variables from the end of the url, because this isn't a url, it's a file system path.

Any variable that's present in the main file will be available in the included/required file. Where is the 41234 value coming from now?