php知识笔记
2014-01-01
php
##写入文件
$fp = fopen($_SERVER['DOCUMENT_ROOT']."/xxx.txt","a+");
fwrite($fp,date("Y-m-d H:i:s",time())."\r\n");
fclose($fp);
##查找文件下所有文件名
$str = '';
$dir = "../Tpl/";
$preg2 = '/[A-Za-z]/';
if (is_dir ( $dir )) {
if ($dh = opendir ( $dir )) {
while ( ($file = readdir ( $dh )) !== false ) {
if (preg_match ( $preg2, $file )) {
$zt = '';
if ($info ['theme'] == $file) {
$zt = 'selected';
}
$str .= '<option value=' . $file . ' ' . $zt . '>' . $file . '</option>';
}
}
closedir ( $dh );
}
}