The GETCHWD () function returns the current working directory. This function returns the current working directory if it succeeds. The failure returns FALSE.
GETCHWD () Function code instance
<?php Echo getcwd (). "<br/>"; echo dirname (FILE);?>
PHP can use the magic constant file to get the absolute path of the current files, regardless of whether the current file is contained by other files, which is very useful in many cases, but sometimes when we read and write files and other operations, relative to the current script working directory, that is, the directory of the portal PHP files, Another function getcwd () provided by PHP can now be used to get
Compare the differences between the two:
<?php if (!defined (' BasePath ')) exit (' No Direct script access allowed '); Include APPPATH. ' libraries/api/base.api.php '; Include APPPATH. ' libraries/api/organ.api.php '; Include APPPATH. ' libraries/api/task.api.php '; Include APPPATH. ' libraries/api/pay.api.php '; Class Notice extends my_controller{public $coid = 0; Public Function Index () { echo getcwd (); Echo ' <br> '; echo FILE; } }
The results of the operation contrast, the difference is at a glance:
/data/html/test.oa/public/data/html/test.oa/application/controllers/notice.php