php中的if(false)是什么意思?

时间:2017-04-11 00:49:05

标签: php wordpress

今天,我决定下载wordpress,我遇到的第一个文件是wp-admin / install.php。文件中的第一件事是:

// Sanity check.
if ( false ) {
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Error: PHP is not running</title>
</head>
<body class="wp-core-ui">
    <p id="logo"><a href="https://wordpress.org/">WordPress</a></p>
    <h1>Error: PHP is not running</h1>
    <p>WordPress requires that your web server is running PHP. Your server does not have PHP installed, or PHP is turned off.</p>
</body>
</html>
<?php
}

现在我有点疑惑,什么是if( false )?如何表示用户没有在他们的服务器上运行php?

2 个答案:

答案 0 :(得分:2)

如果PHP在服务器上运行,则会跳过if ( false )内的语句,因为这相当于 FALSE 或类似if(0)

但是在PHP编译器不存在的情况下,服务器将解析该语句中的所有html代码,(说PHP没有运行)。

这是一次健全检查。

答案 1 :(得分:1)

是的,因为当PHP服务器执行时,条件永远不会成立,因此PHP正在服务器中运行。否则,您将看到表示PHP未运行的HTML。因为php代码是在这种情况下没有执行的。

相关问题