Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combe multiple php files into one?

Status
Not open for further replies.

Korizon67

Programmer
Apr 25, 2007
36
US
Is there a way to combine multiple php files into one file and then call the functions from a main page? I have some menus embedded in a layered form, As it is I have a menu_layer1.php.. menu_layer2_.php and so on... I was sure there was a way to call the file something like include '../menus.php=layer1'; but its been awhile since I messed with this stuff.

What I was hoping to hear is... I can take the files and make something like a class or function for each separate file in a single menu.php then call the function like I did above. is this possible?

thanks for any replies

mike
 
yes

take a look at thread434-1362988 for an example of switchboard based site design (also called the despatch method).
 
sure, its a simple matter of checking the GEt global for the value of layer and proceeding from there:

something like:

Code:
[green]\\Define functions for layer code[/green]

function layer1()
{
[green]\\Layer 1 code[/green]
}

function layer2()
{
[green]\\Layer 2 code[/green]
}

[green]Check GET superglobal and determine which layer function to call:[/green]

if(isset($_GET['layer']){
    if($_GET['layer']=="layer1"){
       layer1();
}
    if($_GET['layer']=="layer2"){
       layer2();
}

}

And you would call your menu.php like:

menu.php?layer=[red]layer1[/red] or
menu.php?layer=[red]layer2[/red] etc..

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thank you for your replies, that is exactly what I needed... now I can get rid of a bunch of extra files :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top