note 92844 modified in function.mkdir by thiago
| From: | thiago@php.net | Date: | Mon, 30 Nov 2009 16:47:38 +0000 |
| Subject: | note 92844 modified in function.mkdir by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-163423@lists.php.net to get a copy of this message | ||
The example from "hinom - iMasters" below is broken -- here's a version that works:
<?php
function handleError() {
trigger_error('MY ERROR');
/** usage sample
@handleError();
echo $php_errormsg;
*/
}
// detect slash/backslash nomenclature dirname
$path = dirname( __FILE__ );
$slash = '/';
(stristr( $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;
}
?>
[EDIT by thiago AT php DOT net: This function has a fix from imran@curl.phptrack.com]
--was--
The example from "hinom - iMasters" below is broken -- here's a version that works:
<?php
function handleError() {
trigger_error('MY ERROR');
/** usage sample
@handleError();
echo $php_errormsg;
*/
}
// detect slash/backslash nomenclature dirname
$path = dirname( __FILE__ );
$slash = '/';
(stristr( $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;
}
?>
http://php.net/manual/en/function.mkdir.php