【问题标题】:Notice: Use of undefined constant success - assumed 'success' [duplicate]注意:使用未定义的常量成功 - 假定“成功”[重复]
【发布时间】:2018-07-02 02:14:51
【问题描述】:

任何能够帮助解决这个烦人的错误的人都尝试了大约 30 分钟。

<?php
if(isset($_POST['statusBtn']))
{
    $username = htmlspecialchars($_POST['address']);
    strtolower($username);
    if(empty($username))
    {
        echo '<center><div class="alert alert-icon alert-danger alert-dismissible fade in col-md-7" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span></button><i class="mdi mdi-check-all"></i>Fill in all fields</div></center>';
    } else if($username == "" || $username == ""){
        echo '<center><div class="alert alert-icon alert-danger alert-dismissible fade in col-md-7" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><i class="mdi mdi-check-all"></i>Domain Whitelisted</div></center>';
    } else {
        $geo = @file_get_contents("http://ip-api.com/json/{$username}");
        $json_a = json_decode($geo, true);
        $proxyid = $json_a['status'];
        if($proxyid == success)
        {
            echo '<center><div class="alert alert-icon alert-success alert-dismissible fade in col-md-7" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><i class="mdi mdi-check-all"></i>'.htmlspecialchars($username).' is Online!</div></center>';
        } else {
            echo '<center><div class="alert alert-icon alert-danger alert-dismissible fade in col-md-7" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><i class="mdi mdi-check-all"></i>'.htmlspecialchars($username).' is Offline!</div></center>';
        }
    }
}
?>

当我以表单形式提交例如 google.com 时,它会回显结果以及错误

注意:使用未定义的常量成功 - 假定为“成功”

【问题讨论】:

  • 你怎么看这个?
  • 请注意,center 标记已过时。

标签: php notice


【解决方案1】:

if($proxyid == success) 更改为if($proxyid == 'success')

错误告诉你success没有' '意味着这是一个常量,而不是一个字符串。

【讨论】:

    猜你喜欢
    • 2013-07-20
    • 2017-01-12
    • 1970-01-01
    • 2016-04-02
    • 2019-02-19
    • 1970-01-01
    • 2020-10-15
    • 2017-12-19
    • 1970-01-01
    相关资源
    最近更新 更多