php 致命错误:无法使用isset,请使用空表达式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33080573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fatal error: Cannot use isset, use null expression
提问by PHP Web Dev 101
I keep receiving the error:
我不断收到错误:
Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in line 42
致命错误:不能在第 42 行的表达式结果上使用 isset()(您可以使用“null !== expression”)
This is line 42:
这是第 42 行:
if (isset($_GET['reply_id'] && $_GET['reply_user'])) {
Here's the "entire" part of that code:
这是该代码的“整个”部分:
<?php
if (isset($_GET['reply_id'] && $_GET['reply_user'])) {
$reply_id = $_GET['reply_id'];
$reply_user = $_GET['reply_user'];
echo '<form action="#" method="post">
<center>
<textarea rows="4" cols="50" maxlength="300" name="comment_box" placeholder="Say something awesome..." Style="width:94%;font-family:helvetica;font-size:14px;">@' . $reply_user . '.</textarea></center>
<center><input type="submit" name="post2" class="post_text" value="Post"></center>
</form>';
}
?>
How do I fix this?
我该如何解决?
回答by invisal
Do you mean
你的意思是
if ( isset($_GET['reply_id'], $_GET['reply_user']) ) {
// code here
}
回答by sandeepsure
Try by replacing with this condition.
尝试用这种情况替换。
if (isset($_GET['reply_id']) && isset($_GET['reply_user'])) {
// your code.
}
回答by TheBosti
Late reply, but usually this error is caused by a typo or syntax error.
迟到的回复,但通常这个错误是由拼写错误或语法错误引起的。
(isset($_GET['reply_id'], $_GET['reply_user']))
(isset($_GET['reply_id']) && isset($_GET['reply_user']))
Both are fine!
两个都好!