A perfect solution to the relative path problem under the PHP command line: PHP Time: October 13, December 18, 2015
Generally, PHP runs as CGI and Apache modules, and PHP rarely runs in CLI. When using include and require in the PHP file under the (CLI) Command Line, you must switch the current working directory before using the relative path. Otherwise, an error is reported and the file cannot be found. Next, let's take a look at the perfect solution to the issue of executing relative paths under the PHP command line (CLI.
$ Cur_dir = dirname (_ FILE _); // Obtain the chdir ($ cur_dir) Directory of the current FILE; // change the current directory to the specified directory. Require (../class/a. php); // introduce the relative path file
In another small detail, when writing a file in PHP for another row, \ r \ n is sometimes invalid. Please check whether \ r \ n is a single quotation mark. double quotation marks must be used here.
In this way, we can use PHP for some scheduled processing when the traffic is small. In fact, in Linux, we can work with the crontab scheduled task. PHP can help us do a lot of things. For example, daily statistics, database backup, log clearing, and some routine maintenance.