php可以操作服务器根目录以外的路径吗
php可以操作服务器根目录以外的路径吗?
具体问题:
php可以操作服务器根目录以外的路径么
比如f盘的一个文件夹
有办法么
回答:
windows 平台所谓的根目录可能是指的系统目录,或者盘符目录。
UNIX以及Linux/GNU系统中根目录特指 Root directory及'/'
以上不深究,我们讨论你提出的问题。
分割线
PHP是一种解释性语言。解释性语言程序是不需要编译的,运行程序时才需由PHP解释器即时编译。这里不要有疑问,php解释器自然是包含在php包内(不细解释,有时间去翻翻资料)。我们在本地解释php语言是没任何用途的,用php自然是要他的特长做web开发。那我们就需要一款web服务器软件来驱动php解释器,好让浏览器与服务器之间形成HTTP协议通信。
PHP支持的web服务器软件很多:Apache、Nginx、Microsoft Internet Information Server(IIS)、Personal web Server(PWS)、Netscape 、iPlant server、Oreilly Website Pro Server、Caudium、Xitami、OmniHTTPd 等等等。这里我们选最熟悉的Apache来举例。
我们可以配置php在Apache作为CGI脚本或者是apache模块或者fastcgi模式来运行。默认的,比如在windows平台基本是作为apache模块来运行。竟然是Apache运行解释器,那自然我们用php语言来增删改文件都属于apache用户身份去执行。
比如apache 配置用户和用户组都是www/www.(网络上有金步国翻译的apache手册,有兴趣可以Google一下)。
windows平台(很多年不使用它了,如果解释有误请包含)
FAT32分区模式下,windows上是无文件权限这个说法的。自然不管是php是放置在哪个盘。只要是系统能访问的盘符,php都能创建文件或者文件夹。
NTFS分区,已经引入文件权限。这里就需要辨别apache用户在要操作的目录下有无权限,如果无则不能产生动作。
UNIX、linxu/GNU
优秀的文件系统权限设计。除了基本的 读 写 执行 权限还能定义隐藏属性和文件特殊权限等等。以及linux的使用者管理建立用户和用户组。如此我们就要遵循文件权限以及用户权限去应用php动作。具体的可以在google搜索详细了解。Linux 文件权限|linux 账号与用户组。
分割线
权限部分,我就不解释了。基本上你需求的深层次点的原理已经基本完整。
更多相关技术文章,请访问PHP中文网!

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

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
