doubi4435 2015-07-18 07:49
浏览 20
已采纳

设置变量,但PHP只是忽略它并覆盖它?

Okay, so, I have a configuration.php, and in there I have this: $baseURL = 'http://www.website.com'; (just hiding my site)

On every page I call the configuration.php, and it doesn't matter what directory or page I'm on (yes I'm setting the configuration.php to the correct directory) but I try to make a image link like this:

<a href="<?php echo $baseURL; ?>"><img src="<?php echo $baseURL; ?>/images/logo.png"></a>

So that should, when clicked, take me to http://www.website.com. Nope, it takes me to the same page. It's like its overwriting itself... I have nothing overwriting it in my code, it just like sets itself to the current page instead of just http://www.website.com

  • 写回答

1条回答 默认 最新

  • duanjuan1103 2015-07-18 08:25
    关注

    I'm not sure why you have a config file to declare the value, and by call, I'm guessing you mean include. If you're not using include, could you tell us what you're doing? More code!

    config.php

    <? $baseURL = "http://" . $_SERVER['SERVER_NAME']; ?>
    

    Then

    <? include "config.php"; ?>
    <a href="<? echo $baseURL; ?>"><img src="<? echo $baseURL; ?>/images/logo.png" alt="logo.png"><? echo $baseURL; ?></a>
    

    Also check for error_log entries related to this, you may find that it tells you exactly what is wrong.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)