Is_dir returns false, even if it is a directory?

Why is_dir () returns false even if it is a directory?

does not return an error

$path_mysql = '/var/lib/mysql/'; if(!is_dir($path_mysql)){ echo 'error'; } 

returns an error

 $path_mysql = '/var/lib/mysql/domain.com/'; if(!is_dir($path_mysql)){ echo 'error'; } 

/var/lib/mysql/domain.com/ executes exsits, but is_dir () returns false !?

I can access the directory through PuTTY and WinSCP

+4
source share
2 answers

Perhaps because he cannot check if /var/lib/mysql/domain.com/ or not, because he does not have enough rights for this (permission problems).

Check the execute (list) permission of the /var/lib/mysql/ directory for the user who runs this PHP script (it may be www-data )

+4
source

Probably permissions - the data for MySQL data belongs to the MySQL user. If you use this test script under a web server, it is very unlikely that the UID of the web server has the right to read anything in this directory, therefore is_dir returns false.

0
source

Source: https://habr.com/ru/post/1380602/


All Articles