How to simplify setting the php project path
This article mainly introduces how to simplify the setting of php project path, the article introduces in great detail, has a certain reference value, interested friends must read it!
Simplify the way to set the php project path: [header ("Content-type:text/html;charset=utf-8"); $webrootpath = $_ SERVER ['DOCUMENT_ROOT']; $easywebroo...].
This article operating environment: windows10 system, php 7, thinkpad T480 computer.
Here are the specific settings to simplify the php project path, which is compatible with all operating systems. Let's take a look at it.
Header ("Content-type:text/html;charset=utf-8"); / / server root directory $webrootpath = $_ SERVER ['DOCUMENT_ROOT']; / / succinctly get server root directory $easywebrootpath = "$DOCUMENT_ROOT\\ DEMO\\ 20150418\ ss.txt"; / / current folder directory, which proves that there is no problem in mixing forward slash and backslash under windows $dirnamepath = dirname (_ _ FILE__).' / ss.txt' / / because windows can only use forward slashes and forward slashes, other systems can only use forward slashes, and forward slashes are compatible with all systems, so replace all backslashes with forward slashes $newwebrootpath = str_replace ("\", "/", $easywebrootpath); $fp = fopen ($newwebrootpath,'a'); fwrite ($fp, hello); fclose ($fp); echo'$webbrootpath';echo "$webrootpath"; echo $webrootpath. "; echo $easywebrootpath.'';echo $dirnamepath.'' Echo "forward slash:". The above $newwebrootpath; is all the contents of the article "how to simplify setting the php project path". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!