PHP : Cara membuat banyak halaman dengan fungsi $_GET

Wednesday, May 6, 20150 comments

Sebetulnya dengan satu file PHP kita bisa membuat banyak halaman hanya dengan fungsi $_GET dan if else saja, untuk lebih jelasnya perhatikan script berikut:

file contoh test.php
<?php
if( $_GET['page'] == "2" ){
  echo 'Ini Page 2 yang ber-address http://localhost/test.php?page=2';
  echo '<a href="/test.php" >page 1</a> | <a href="/test.php?page=3" >page 3</a>';
} elseif( $_GET['page'] == "3" ){
  echo 'Ini Page 3 yang ber-address http://example.com/test.php?page=3';
  echo '<a href="/test.php" >page 1</a> | <a href="/test.php?page=2" >page 3</a>';
} else{
  //Ini halaman utama
  echo 'Ini adalah halaman utama';
  echo 'go to <a href="/test.php?page=2" >page 2</a> | <a href="/test.php?page=3" >page 3</a>';
}
?>

Jika masih bingung silahkan berkomentar di bawah :)
Share this article :

Post a Comment

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Tutorial Web Programming - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger