hello guys, I want to include a php file like include("p.php?id=1") but I get an error. is there any alternatives to use a function like that?
If you are including a file, it is local to the file/function/class you are including it in - any variables that are in scope will be accessible. I.E if p.php is; <?php print "ID = $id\n"; ?> PHP: and you call it from; <?php $id = 1; include 'p.php'; ?> PHP: $id is still in scope, so the result is; ID = 1 This includes query vars and such.
i know this way but it's not only p.php. there are profile.php?id=1, video.php?id=[number] etc I need to include these pages into loader.php i.e a site url is somesite.com/simple.php#!/profile.php?id=1 loader.php becomes like, <? $page = $_GET['page']; // now $page is profile.php?id=1 include($page); ?>
$parts = parse_url($_GET['page']); $pieces = explode('=', $parts['query']); $$pieces[0] = $pieces[1]; print_r($id); include($parts['path']); Code (markup): I hope this help