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 );       
} 

 Answers

2

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
1

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: http://confluence.jetbrains.com/display/PhpStorm/PHPUnit+Installation+via+Composer+in+PhpStorm

Related usability ticket: http://youtrack.jetbrains.com/issue/WI-18388

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

Sunday, July 31, 2022
 
4

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
3

Use SHOW INDEX like so:

SHOW INDEX FROM [tablename]

Docs: https://dev.mysql.com/doc/refman/5.0/en/show-index.html

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

 INSERT INTO ResultSet
 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