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

从php获取脚本URL

I have a PHP file (mymainfile.php)

inside this PHP file, i have include some other PHP files (include.php).

The URL is:

http://www.domain.com/my/mymainfile.php

Now i want to get the URL into a variable inside the include.php file.

All my tries with the $_SERVER variables will give me "domain.com/my/include.php" back and that's not what I'm looking for.

Is it possible, and if it's, how?

Have you tried getcwd()? http://php.net/manual/en/function.getcwd.php Or dirname(__FILE__) (or just __FILE__ ) Aand 1 more try

function get_file_dir() {
    global $argv;
    return realpath($argv[0]);
}

近期文章

  • 关于#matlab#的问题:问题遇到的现象和发生背景
  • 谁有这款类似的手机端社区论坛
  • 如何制作rpm安装包,使支持prefix选项
  • Centos7:关于多IP出口网络配置的问题
  • 正则表达式判断sda1和sda
  • 工业级安卓车机芯片推荐
  • tomcat的server.xml配置
  • Oracle安装包 19c
  • vs2019 int x=stoi(s)加上去解决方案生成成功,但无法执行
  • python报错,SyntaxError: invalid syntax
  • C# grouppanel的覆盖问题
  • python问题,在线求解!
  • 下面的python代码,第二三行有什么区别吗?
  • 关于#idea#创建空项目的问题(语言-java)
  • Camstar 协助工具,请求收费共享
  • java游戏服务器连接时机
  • fastjson漏洞怎么利用?
  • linux网络服务应用的安装与部署
  • MySQL update语句同时更新多列的问题
  • 用selenium进行爬虫时怎么解决登录弹窗问题

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

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

友情链接:代码精华