- 论坛徽章:
- 0
|
新做一站点。
全是面向过程的。
做的时候每个功能用一个文件来写。。
比如新闻news.php 新闻查看newsview.php 新闻添加 newsadd.php
想改成单一入口的。、
news.php?action=请求
调用不用的文件来处理
<?php
require('common.php');
$query_string = $_SERVER['QUERY_STRING'];
$array= array('add', 'view'....);
$sources_file = preg_match('/^[a-z_]+$/', $query_string) && in_array($query_string, $array) ? $query_string : 'home';
$sources_file_path = dirname(__FILE__).'/sources/'.$sources_file.'.php';
if(file_exists($sources_file_path))
{
require($sources_file_path);
}
else
{
exit('<b>'.$sources_file.'</b> file not exists');
}
?> |
总感觉这样的URL不美观 -_-!!
于是又改成news.php?动作
还是感觉不爽。。
大家有啥好的建议?不
[ 本帖最后由 tangwenming 于 2008-6-11 23:37 编辑 ] |
|