PHP Help: require() in particular....

jtusa

Diamond Member
Aug 28, 2004
4,188
0
71
Using the require function to load pages into a table. Table controls the layout, page being loaded is the actual content page. Anyways, I figured the easiest part would be to use

"index.php?page=pagenamehere" and then use the $page variable in the require to load whatever the variable says.

Well it works except it loads the page, then loads the page again, and again, and again, and I'm not sure how to make it stop.

THere a better was to do this or how do I stop it from looping?
 

stndn

Golden Member
Mar 10, 2001
1,886
0
0
require_once() is probably what you need.
It only includes the page once.
 

jtusa

Diamond Member
Aug 28, 2004
4,188
0
71
There a way to give the variable a default value, but then be able to change it like stated above?
 

Zugzwang152

Lifer
Oct 30, 2001
12,134
1
0
Originally posted by: jtusa4
There a way to give the variable a default value, but then be able to change it like stated above?

<?php

$pname = "default_value";

if(isset($_GET["page"])) {

$pname = $_GET["page"];

}


?>