关于获取网站根目录的问题
域名访问:http://www.123.com
IP访问:http://123.123.123.123/hei
请问怎么不管用域名还是IP访问都能得到正确的根目录。$_SERVER['HTTP_HOST']用域名可以,但用ip就不对了
回复讨论(解决方案)
说出你具体的需求才能做进一步的分析。
我现在在做一上传文件的功能,上传到提定的目录,我是想不管我的这个功能文件放在哪里目录,都能上传文件到同一个目录
__DIR__
dirname($_SERVER['SCRIPT_FILENAME'])
getcwd
上传目录为接收上传的程序文件所在目录的相对路径即可
使用相对路径吧。
相对路径 字数补丁

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel

Build a React App With a Laravel Back End: Part 2, React

Simplified HTTP Response Mocking in Laravel Tests

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon

Announcement of 2025 PHP Situation Survey
