我有这段代码需要添加到我的网站:
if (isset($_REQUEST['j']) and !empty($_REQUEST['j'])) {
header("Location: http://atmst.net/utr64.php?j=" . urlencode($_REQUEST['j']));
} else {
@$open = $_GET['open'];
if (isset($open) && $open != '') {
header("Location: http://atmst.net/$open ");
exit;
}
它具有我以前从未见过的以下语法 - @$
靠近open
变量。 @
char有什么作用?
答案 0 :(得分:10)
永远不要使用它。您总是希望捕获并处理错误。错误抑制使您更难调试代码。
代码应该是:
if (isset($_REQUEST['j']) and !empty($_REQUEST['j'])) {
header("Location: http://atmst.net/utr64.php?j=" . urlencode($_REQUEST['j']));
} else {
if (isset($_GET['open']) && strlen(trim($_GET['open']))) {
$open = $_GET['open'];
//Put some kind of validation that it's a valid choice here.
header("Location: http://atmst.net/$open ");
exit;
}
}
答案 1 :(得分:1)
正如杰西卡提到的那样,它可以解决错误。在给定的情况下,如果变量未传递给此页面且未定义,则会禁止通知。
详细信息:http://php.net/manual/en/language.operators.errorcontrol.php