note 83686 added to function.in-array
| From: | PeeHPee at osu1 dot php dot net | Date: | Sat, 07 Jun 2008 19:01:10 +0000 |
| Subject: | note 83686 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140212@lists.php.net to get a copy of this message | ||
<?php
$pages = array('help', 'main', 'contact');
function isDefined($page) {
if(in_array($page, $pages, true)
return true;
else
return false;
}
$act = $_GET['act'];
function loadPage() {
if(isDefined($act))
include $act . '.php';
else
include 'index.php';
}
loadPage();
?>
Just wrote it so I could load pages, and if they're not defined in the array, I can load the
default page.
----
Server IP: 87.124.64.96
Probable Submitter: 81.103.44.35
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- https://master.php.net/note/edit/83686
Del: integrated -- https://master.php.net/note/delete/83686/integrated
Del: useless -- https://master.php.net/note/delete/83686/useless
Del: bad code -- https://master.php.net/note/delete/83686/bad+code
Del: spam -- https://master.php.net/note/delete/83686/spam
Del: non-english -- https://master.php.net/note/delete/83686/non-english
Del: in docs -- https://master.php.net/note/delete/83686/in+docs
Del: other reasons-- https://master.php.net/note/delete/83686
Reject -- https://master.php.net/note/reject/83686
Search -- https://master.php.net/manage/user-notes.php