Hướng dẫn php chdir not working
I'm developing a PHP cron script to check if a server is up or not (Ping). Show Here is my code :
So at the first line, I need to make a I tested the script with Chrome and all worked fine but when I execute the script with command-line, PHP drop this error :
I searched why PHP drop this but I can't find any answer. Do anyone knows why this is happening ? Thank you !! (PHP 4, PHP 5, PHP 7, PHP 8) Nội dung chính chdir — Change directory Descriptionchdir(string Parametersdirectory The new current directory Return Values Returns Errors/Exceptions Throws an error of level ExamplesExample #1 chdir() example
The above example will output something similar to: /home/vincent /home/vincent/public_html NotesCaution If the PHP interpreter has been built with ZTS (Zend Thread Safety) enabled, any changes to the current
directory made through chdir() will be invisible to the operating system. All built-in PHP functions will still respect the change in current directory; but external library functions called using FFI will not. You can tell whether your copy of PHP was built with ZTS enabled using php -i or the built-in constant See Also
nesk at xakep dot ru ¶ 1 year ago
= 'path/to/libraries'; php dot duke at qik dot nl ¶ 13 years ago
;
herwin at snt dot utwente dot nl ¶ 16 years ago
How do I move up a directory in PHP?If you are using PHP 7.0 and above then the best way to navigate from your current directory or file path is to use dirname(). This function will return the parent directory of whatever path we pass to it. How do I view a directory in PHP?PHP scandir() Function $b = scandir($dir,1); What is chdir in PHP?The chdir() function changes the current directory. What is __ DIR __ in PHP?The __DIR__ can be used to obtain the current code working directory. It has been introduced in PHP beginning from version 5.3. It is similar to using dirname(__FILE__). Usually, it is used to include other files that is present in an included file. |