PHP gets the absolute path to the file

Source: Internet
Author: User

1234567891011121314151617181920212223242526272829303132 ===========PHP获取文件绝对路径=======<?php   echo__FILE__// 取得当前文件的绝对地址,结果:D:\www\test.php   echodirname(__FILE__); // 取得当前文件所在的绝对目录,结果:D:\www\   echodirname(dirname(__FILE__)); //取得当前文件的上一层目录名,结果:D:\?>===========PHP获取文件绝对路径==================chdir() 函数===========定义和用法chdir() 函数把当前的目录改变为指定的目录。若成功,则该函数返回 true,否则返回 false。语法chdir(directory)参数 描述directory 必需。规定新的当前目录。例子<?php//获得当前目录echogetcwd();echo"<br />";//改变为 images 目录chdir("images");echo"<br />";echogetcwd();?> 输出:C:\testweb\mainC:\testweb\main\images===========chdir() 函数===========

PHP gets the absolute path to the file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.