Php 未定义常量控制台的使用

Php 未定义常量控制台的使用,php,Php,我收到通知说: Use of undefined constant console - assumed 'console' 当我尝试在控制台中打印变量的值时 if(!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])){ header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: Basic realm="asr-web-dev1

我收到通知说:

Use of undefined constant console - assumed 'console'
当我尝试在控制台中打印变量的值时

if(!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])){
    header('HTTP/1.1 401 Unauthorized');
    header('WWW-Authenticate: Basic realm="asr-web-dev1"');
    exit('<h3>Sorry!</h3><p>You must enter your username and password to log in and access this site.');
}

$db = new ezSQL_mysql(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
$username = trim($_SERVER['PHP_AUTH_USER']);
$password = trim($_SERVER['PHP_AUTH_PW']);
$count = $db->get_var("select count(*) as count from users WHERE user_name='" . $username . "' AND password='" . $password . "'");

if($count == 1){ 
    $data = $db->query("SELECT * FROM users WHERE user_name='" . $username . "' AND password='" . $password . "'");
    console.log($data);
    $user_id = $data['user_id'];
    $name = $data['name'];
} else {
    header('HTTP/1.1 401 Unauthorized');
    header('WWW-Authenticate: Basic realm="asr-web-dev1"');
    exit('<h3>Sorry!</h3><p>You must enter your username and password to log in and access this site.');
}

php中没有JS控制台对象


而不是console.log$数据;使用echo$数据;或打印r$数据;或var_dump$数据

或者,您可能只是在寻找PHP函数error\u log来编写错误日志。下面是PHP手册的链接,解释了该函数的工作原理

console.log是Javascript;不是PHP。。。你希望这能做什么?如果您想输出一些东西,请使用print、echo、print\u r或var\u dump.console.log。对于js,请使用var\u dump而不是eadconsole.log$data;是不是PHP.console.log???。您使用的是js还是PHP?虽然在这种情况下,错误是关于哪一行的,但在引用指定行号的错误消息时,请确保包含的代码与错误匹配。在本例中,console.log$data;语句不在您提供的代码的第19行。在更复杂的情况下,如果错误中报告的行号与提供的代码不匹配,可能会浪费其他人大量的时间。或var_dump$data;:-同意火箭。请注意,echo不会为假变量输出任何内容。print_r有其自身的局限性,尤其是在处理对象时。var_dump将始终为您提供三者中最多的信息。