PHP $ SITE_URL Messing

时间:2017-04-06 18:24:30

标签: php

我们在自己的Windows服务器上托管一个WordPress网站工作正常,但几天后才发现有一个PHP联系表单,它发送带有单选按钮的PDF附件,当它在Godaddy上托管时工作正常,现在问题是没有加载单选按钮我发现URL是

<img src=\"$SITE_URL/patientform/ckedimage.png\"/>

并且$ site_url是

$SITE_URL="http://".$_SERVER['SERVER_NAME'];

我认为它提取本地服务器名称,如何将网站URL设置为domain.com?

整个代码

<?php

$SITE_URL="http://".$_SERVER['SERVER_NAME'];

$cnt1=1;
foreach($caffinarr as $sympKey=>$sympVal6)
{
if(in_array($sympVal6, $caffinevalue))
        {

            $html .="<td><img src=\"$SITE_URL/patientform/ckedimage.png\"/>
            <td>$sympVal6 </td>";
        }
        else
        {
            $html .="<td><img src=\"$SITE_URL/patientform/uncheckedimage.png\"/>
            <td >$sympVal6</td>";

1 个答案:

答案 0 :(得分:0)

修复您的代码

<?php

 $SITE_URL = 'http://'.$_SERVER['SERVER_NAME'];
$dir = "/patientform/ckedimage.png";
//echo $SITE_URL.$dir;
?>
<img src="<?php echo $SITE_URL.$dir; ?>" />

这就是你的代码:

<?php



 $SITE_URL = 'http://'.$_SERVER['SERVER_NAME'];
$dir = "/patientform/ckedimage.png";
$dir_uncheck = "/patientform/uncheckedimage.png";
//echo'<img src="'.$SITE_URL.$dir.'" />';

$cnt1=1;
foreach($caffinarr as $sympKey=>$sympVal6)
{
if(in_array($sympVal6, $caffinevalue))
        {

            $html ='<td><img src="'.$SITE_URL.$dir.'" />
            <td>'.$sympVal6.'</td>';
            echo $html;
        }
        else
        {
              $html ='<td><img src="'.$SITE_URL.$dir_uncheck .'" />
            <td>'.$sympVal6.'</td>';
            echo $html;

            ?>