Skip to content

Instantly share code, notes, and snippets.

@bangiqi
Last active August 29, 2015 14:21
Show Gist options
  • Save bangiqi/b7ab9a43d9c368de20c5 to your computer and use it in GitHub Desktop.
Save bangiqi/b7ab9a43d9c368de20c5 to your computer and use it in GitHub Desktop.
membuat website pribadi terdiri dari 4 menu [ home , my future, my job, contact ] , untuk halaman [aboutus.php, home.php, profile.php] dimasukan kedalam folder pages, dan script masing-masing file adalah sebagai berikut :
<?php
echo "about us";
?>
<?php
echo "halaman home";
?>
<a href="index.php">Home</a>
<a href="index.php?p=profile">Profile</a>
<a href="index.php?p=aboutus">About Us</a>
<br/>
<br/>
<?php
$pages_dir = 'pages';
if(!empty($_GET['p'])){
$hal = scandir($pages_dir, 0);
unset($hal[0], $hal[1]);
//var_dump($hal);
$p = $_GET['p'];
if(in_array($p.'.php', $hal)){
include($pages_dir.'/'.$p.'.php');
}else{
echo 'Halaman tidak ditemukan! :( ';
}
}else{
include('pages/home.php');
}
?>
<?php
echo "halaman profile";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment