The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
Onefile PHP Script
Posted by: Stephen | February 10, 2007 @ 11:03am
PHP Code
[
Download
]
<?php // Name: Onefile PHP Script // Description: One PHP file can host multiple pages with this script. // Usage: index.php?page=1 // Original script: Andy @ http://abyssunderground.co.uk // This script modified by Stephen Lance switch ($_GET['page']) { case 0: defaultPage(); break; case 1: page1(); break; case 2: page2(); break; case 3: page3(); break; default: defaultPage(); } function defaultPage() { echo "<HTML><HEAD><TITLE>Default Page</TITLE></HEAD><BODY>"; echo "Here's the HTML for the default page."; echo "<P>Links:<BR><BR>"; echo "<a href=\"http://{$_SERVER[HTTP_HOST]}{$_SERVER[PHP_SELF]}\">Default Page</a><BR>"; echo "<a href=\"http://{$_SERVER[HTTP_HOST]}{$_SERVER[PHP_SELF]}?page=1\">Page 1</a><BR>"; echo "<a href=\"http://{$_SERVER[HTTP_HOST]}{$_SERVER[PHP_SELF]}?page=2\">Page 2</a><BR>"; echo "<a href=\"http://{$_SERVER[HTTP_HOST]}{$_SERVER[PHP_SELF]}?page=3\">Page 3</a><BR>"; echo "</BODY></HTML>"; } function page1() { echo "<HTML><HEAD><TITLE>Page 1</TITLE></HEAD><BODY>"; echo "Here's the HTML for the page 1."; echo "</BODY></HTML>"; } function page2() { ?> <HTML> <HEAD> <TITLE> </TITLE> </HEAD> <BODY> <P>Here is the HTML. Don't need to worry about PHP here because we're outside of the PHP tag. Then before this function ends, we're back in PHP.</P> <P>Any static content might as well be outside the PHP tags.</P> <P>To go back inside, just do this: (look at the source code)</P> <PRE>Page ID: <?php echo $_GET['page']; ?></PRE> <?php } function page3() { header("Content-type: text/plain"); echo "This is just plain text."; } ?>
Syntax Highlighting
[
Open in new window
]
Author Comments
This code allows you to call multiple webpages, all served with by one PHP file.
Rating
4.40 / 8
638 Votes