אשכול: עזרה ב- page?.
View Single Post
ישן 02-11-08, 12:10   # 6
Jonathan Zeierman
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Jun 2007
הודעות: 1,003

Jonathan Zeierman לא מחובר  

ציטוט:
נכתב במקור על ידי vadimg88 צפה בהודעה
טעות קטנה בקוד זה אמור לעבוד:

PHP קוד:
<?php


$page 
trim(stripslashes($_GET['page']));
// $page = intval($page); // if the $page can be only a number uncomment this line


// the array of choices that can be used
# What to do?
$choice = array(
"contact"        => array( "contact"             'contact'       , array() ),
"page"         => array( "page"             'page'       , array() ),
"index"         => array( "index"             'index'       , array() ),

);


$page = isset($page) ? $page 'index';

if( 
is_array($page) )
{
    
$page 'idx';
}

# Check to make sure the array key exits..
if ( ! isset($choicestrtolower($page) ][0]) )
{
    
$page 'idx';
}

# Redirect to a page
header('Location: index.php?page='.$loaded);

# Load a file
# REQUIRE AND RUN
require( ROOT_PATH $choicestrtolower($page) ][0].".php" ); // load the file xx.php
$runme = new $choicestrtolower($page) ][1]; // call the class xx
$runme->auto_run(); // run it


// etc...



?>
שים לב ששמתי את האלמנט הראשון במערך. זאת אומרת שאם תיגש לקישור index.php?page=contact זה יפנה לקישור index.php?page=contact
במידה ויש לטעון קובץ זה יטען קובץ contact.php
לא עובד,
http://www.zeierman.co.il/yoni/get.php
והנה הדף contact
http://www.zeierman.co.il/yoni/contact.php
__________________
יונתן.
אימייל: jonathan@zeierman.net
  Reply With Quote