这里的功能是一个简约的类,应该工作,但没有测试。
<?php
class URLHandler
{
public $get;
public function __construct($get);
{
$this->get = $get;
}
public function get_var($var)
{
return htmlspecialchars($this->get[$var]);
}
public function check_var($var, $is)
{
if($this->get_var($var) == $is)
{
return true;
}
else
{
return false;
}
}
}
// Below is how you can use this class
$URL = new URLHandler($_GET);
if($URL->check_var('var1', 'a'))
{
echo 'yes your first var is a';
// Here you can add a function or functions which should be loaded if var1 = a
}
else
{
echo 'No, your first var is not a, its '.$URL->get_var('var2');
// Here you can add a function or functions which should be loaded if var1 is not a
}
if($URL->check_var('var2', 'a'))
{
echo 'and your second var is a';
}
else
{
echo 'your second var is not a, its '.$URL->get_var('var2');
}
?>
希望如果你想访问网址参数,就可以使用这个字符串,帮助 艾哈迈德
你说的是与您(从例如数据库)访问字符串中包含您的网站或网址的网址吗? – 2010-06-03 10:58:18
我正在讨论用于访问您的网站的网址。 – 2010-06-03 11:10:55