note 85821 deleted from function.mkdir by crell

From: Date: Wed, 29 Jun 2022 19:18:37 +0000
Subject: note 85821 deleted from function.mkdir by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218716@lists.php.net to get a copy of this message
Note Submitter: hinom - iMasters ---- mkdir simple test with "exception handler" <?php function handleError() { trigger_error('MY ERROR'); /** usage sample @handleError(); echo $php_errormsg; */ } // detect slash/backslash nomenclature dirname $path = dirname( __FILE__ ); $slash = '/'; strpos( $path, $slash ) ? '' : $slash = '\\'; define( 'BASE_DIR', $path . $slash ); $folder = time(); // folder name $dirPath = BASE_DIR . $folder; // folder path // print results echo $slash; echo '<hr>'; $rs = @mkdir( $dirPath, '0777' ); @handleError(); if( $rs ) { // print success information echo 'was done!'; echo '<br>folder: <a href="' . $folder . '">' . $folder . '</a>'; echo '<br>dirPath: ' . $dirPath; }else{ // print error information echo 'an error was occurred. Attempting create folder'; echo '<br>dirPath: ' . $dirPath; echo '<br>php_errormsg: ' . $php_errormsg; } ?>

« previous php.notes (#218716) next »