2016-07-28 09:00
浏览 425

<?php echo base_url();?>和<?php base_url();?>

 <script src='<?php base_url();?>assets/js/jquery.min.js'></script>

the script above is code that my friend use, that works just for him, but if i change it to <?php echo base_url();?> and it's work for me, not for him.
It's become a problem when we transfer files each other, What i am supposed to do ? thank you.

I've solution script for my case, change this from config.php : $http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://'; $urlbaru = str_replace("index.php","", $_SERVER['SCRIPT_NAME']); $config['base_url'] = "$http" . $_SERVER['SERVER_NAME'] . "" . $urlbaru;

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doushe2513 2016-07-28 09:08

    Please show more about your problem detail like paste your error code in here that we could use those information to help you.

    Btw, base_url() isn't a php embedded function, one of the potential problem is that your friend custom a function named base_url() that supposed to return it's root path. So, you have to either include or build the same function with the same name to your script.


    function base_url()
      return dirname($_SERVER['SCRIPT_FILENAME']);

    And the 'src' inside your tag should point to your jQuery source file.

    解决 无用
    打赏 举报
  • douguluan5102 2016-07-28 09:33

    Looks like you are using codeigniter framwork, and you have not autoloaded URL helper, that's why you getting error. if I am not wrong you have to load URL helper.

    解决 无用
    打赏 举报

相关推荐 更多相似问题