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

时间:2012-08-30 10:32:28

标签: 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配置变量。

3 个答案:

答案 0 :(得分:2)

url(something)是“这是一个网址”的CSS

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

答案 1 :(得分:1)

来自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常量生成的。

答案 2 :(得分:1)

BASE_PATH是named constant,很可能会输出您的webroot的位置/存储图像的位置。

define('BASEPATH', '/path/to/imagefolder/');
相关问题