$array = explode( / , $_SERVER[ REQUEST_URI ]);
$count = count($array);
extract($array, EXTR_PREFIX_ALL, var );
can the variables (created using extract function) be isseted automatically? to avoid "Notice: Undefined variable:" errors when error_reporting(E_ALL); is enabled.
thank you
I tried doing something of this sort, still needed to isset() whenever, the variables are used next in the code (when error_reporting(E_ALL); is enabled).
if(isset($var_0))
{
$var_0 = filter_var($var_0, FILTER_SANITIZE_STRING);
}
if(isset($var_1))
{
$var_1 = filter_var($var_1, FILTER_SANITIZE_STRING);
}
if(isset($var_2))
{
$var_2 = filter_var($var_2, FILTER_SANITIZE_STRING);
}
if(isset($var_3))
{
$var_3 = filter_var($var_3, FILTER_SANITIZE_STRING);
}
==========================
或者,如果条件允许,就对一行进行了审判,
$var_0 = isset($var_0) ? filter_var($var_0, FILTER_SANITIZE_STRING) : ;
$var_1 = isset($var_1) ? filter_var($var_1, FILTER_SANITIZE_STRING) : ;
$var_2 = isset($var_2) ? filter_var($var_2, FILTER_SANITIZE_STRING) : ;
$var_3 = isset($var_3) ? filter_var($var_3, FILTER_SANITIZE_STRING) : ;
虽然错误被忽略,但产生了一个新问题,即变数(如果情况处理,并非由采掘功能造成的变数正在形成)。
我在网站上张贴了两个路由规则(两个航程)。
$pagename = "not-found.php";
//Different Routing Engine Rules follows
if ((isset($var_1)) && (($var_1 == "") || ($var_1 == "index.php"))) {
if((isset($var_2)) || (isset($var_3)) || (isset($var_4)) || (isset($var_5)) || (isset($var_6)) || (isset($var_7)))
{
$pagename = "not-found.php";
}
else
{
$pagename = "default-home.php";
}
}
if (($var_1 == "login"))
{
//echo "Login Page URL
";
if((isset($var_2)) || (isset($var_3)) || (isset($var_4)) || (isset($var_5)) || (isset($var_6)) || (isset($var_7)))
{
$pagename = "not-found.php";
}
else
{
$pagename = "login.php";
}
}
include "code/" . $pagename;
感谢您的帮助。