Include script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Include script

Post by JKM »

Hello,

I wan't an include script that does the following thing, and I wondered if someone could help me out.
  • It's three separate folders - 'hello', 'hi' and 'bye'.
  • index.php should show lol.php
  • index.php?p=hello should show /hello/index.php and so on.
  • index.php?p=hello&page=1 should show /hello/index_2.php and so on.
  • index.php?p=hello&lol=1 should show /hello/lol_1.php and so on.
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: Include script

Post by ghurtado »

Try anything yet?
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Re: Include script

Post by Bill H »

Homework?
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: Include script

Post by JKM »

I've tried, yes. I think this would work, but I don't know how It can work for both 'hi', 'hello' and 'bye'.

Code: Select all

<?php 
if($_GET['p']){
    $page = (isset($_GET['page'])) ? '_'.$_GET['page'] : '';
    
    if(isset($_GET['hello'])) {
        include 'hello/index.php'
    }
    if(file_exists($_GET['lol'].$page.'.php')) {
        include $_GET['hello/lol'].$page.'.php';
    }
}
?>
Post Reply