需要帮助理解 php 中的一段代码


Need help understanding a piece of code in php

<?php 
if($sitedown==true) {
echo <<<MESSAGE
<div style="width: 700px; height: 328px; background: transparent url({${constant(BASE_PATH)}}/images/down.jpg) top left no-repeat;">
<p style="font-size: 20px; font-weight: bold; color: #666; font-family: tahoma, arial; margin: 0px; padding: 100px 10px 0px 200px;">
</p>
</div>
}
?>

url({${constant(BASE_PATH)}}到底是做什么的? BASE_PATH是一个 php 配置变量。

url(something)是CSS,表示"This is a URL">

${constant(BASE_PATH)}应该给你一个字符串(应该是 URL(,它被内插到字符串文字中。

来自 PHP 手册: constant() is useful if you need to retrieve the value of a constant, but do not know its name. I.e. it is stored in a variable or returned by a function.

url()是一个 css "函数",用于从 URL 中(可能(检索一些图像。

在上面的代码中,URL可能是从PHP常量生成的。

>BASE_PATH是一个命名常量,最有可能输出您的 webroot 的位置/存储图像的位置。

define('BASEPATH', '/path/to/imagefolder/');
相关文章: