這裏的功能是一個簡約的類,應該工作,但沒有測試。
<?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