2017-04-11 107 views
0

今天,我决定下载wordpress,我遇到的第一个文件是wp-admin/install.php。文件中的第一件事情是这样的:在php中if(false)是什么意思?

// 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

如果PHP是在服务器上运行,里面if (false)该语句将被跳过,因为这相当于FALSE或其类似if(0)

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

这是一个健康检查。

1

是的,因为当PHP服务器执行时,条件永远不会是真的,因此PHP正在服务器中运行。否则,你会看到说PHP没有运行的HTML。因为php代码是在这种情况下没有被执行的东西。