我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

如何将目录路径转换为完整URL

I want to convert directory paths to absolute URLs. For eg.

    C:\example\myfile to http://example.com/myfile

How can I do this? Please help me.

Use the $_SERVER['SERVER_NAME'] property to get the domain you are running on, then append it to the root of your file location.

i.e. If file is in C:\www\mydir\myfile.file, then

$url = $_SERVER['SERVER_NAME'].'/mydir/myfile.file';

Use preg_replace.

近期文章

  • 带有小数点舍入的PHP浮点数
  • 控制器上的Codeigniter未定义属性
  • 两个客户的PHP会话重叠
  • PHP ZF2单元测试调度方法非常慢
  • php动态HTML单元格意外生成
  • Opencart和VQmod问题修改文件
  • 在单个函数中使用Insert和Update
  • Codeigniter所有URL都转到默认控制器
  • 必须在css文件中使用PHP运行计数器
  • 不能将承诺的价值返还给paypal按钮
  • 解析错误:串联PHP中的语法错误
  • PDO MySQL调用返回无缓冲的查询错误
  • php:如何在类中运行一个方法?
  • 在MySQL中使用XML函数的示例。 PHP
  • PHP在程序编程中避免全局变量
  • 将变量从一个PHP文件传递到另一个PHP文件
  • 从Controller返回到View Laravel 5的逻辑
  • Laravel组间隔10分钟/一天
  • 检查电子邮件是否已激活不工作[关闭]
  • mysql error.Error在sql查询的语法中

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华