note 21001 deleted from function.mkdir by aidan

From: Date: Sun, 03 Oct 2004 13:40:11 +0000
Subject: note 21001 deleted from function.mkdir by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77844@lists.php.net to get a copy of this message
Note Submitter: esm at vania dot dk ---- Neat little function by gjukema@jukeware.com! ============================================= I timed it (using PEARs benchmark class) and compared it with calling exec() this is the lines of codes that I timed: function ForceDirectories( $path) { if ( strlen( $path) == 0) { return 0; } // if ( strlen( $path) < 3) { return 1; // avoid 'xyz:\' problem. } elseif ( is_dir( $path)) { return 1; // avoid 'xyz:\' problem. } elseif ( dirname( $path) == $path) { return 1; // avoid 'xyz:\' problem. } return ( ForceDirectories( dirname( $path)) and mkdir( $path, 0775)); } function xForceDirectories( $path) { exec('mkdir -p ' . $path); } I called both functions with (SOME_DIR . '/1/2/3/4/5/6') here are the results 1 time 100 times (avg.) ForcedDirectories 0.0020860433578491 0.00018657803535461 xForcedDirectories 0.0098119974136353 0.0092913997173309 (create dir) (dir is already created) Not very scientific I know, but I also know what I am going to use :) BTW. The figures are similar on a win32 box

« previous php.notes (#77844) next »