Asked  2 Years ago    Answers:  5   Viewed   73 times

I want to create a directory if it does not exist already.

Is using the is_dir function enough for that purpose?

if ( !is_dir( $dir ) ) {
    mkdir( $dir );       

Or should I combine is_dir with file_exists?

if ( !file_exists( $dir ) && !is_dir( $dir ) ) {
    mkdir( $dir );       



Both would return true on Unix systems - in Unix everything is a file, including directories. But to test if that name is taken, you should check both. There might be a regular file named 'foo', which would prevent you from creating a directory name 'foo'.

Sunday, November 13, 2022

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario:

Related usability ticket:

P.S. The WI-18388 ticket is already fixed in v8.0

Sunday, July 31, 2022

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Sunday, November 6, 2022

Use SHOW INDEX like so:

SHOW INDEX FROM [tablename]


Wednesday, September 7, 2022
 CREATE TABLE ResultSet (Directory varchar(200))

 EXEC master.dbo.xp_subdirs 'c:'

 Select * FROM ResultSet where Directory = 'testing'

Will return a list of sub directories, you can then check the contents of the list.

Tuesday, December 27, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :

Browse Other Code Languages