1,PHPRead sql server varchar field data, the select result is incomplete
Mssql_query() reads varchar type by default and only takes 255 bytes of data. If the field exceeds this Range, use CONVERT(TEXT, table.comment) to convert the field type to TEXT.
$q = "SELECT CONVERT(TEXT, userinfo.inv) as te FROM userinfo where (1=1)";
2. Time
$shijianchuo = strtotime("$logintime"); $past_logintime = date("Y/m/d",$shijianchuo-24*60*60); $today_time=date("Y-m-d"); $zh_time = strtotime("$today_time"); $yesterday_time= date("Y-m-d ",strtotime("-1 day","$zh_time")) ; $tomorrow_time= date("Y-m-d ",strtotime("+1 day","$zh_time")) ;
3. PHP time displays am and pm. Modify phpini
Modify php.ini, find;mssql.datetimeconvert = On, remove the previous points No., change on to off, restart apache or iis
4, pop-up box
5, copy directory
$filecount=0; $dircount=0; function copydir($dirFrom,$dirTO) { global $filecount; global $dircount; if(is_file($dirTO)) { die("目标不是目录,无法创建目录 $dirTO"); } if(!file_exists(dirTO)) { mkdir($dirTO); $dircount++; } $handle=opendir($dirFrom); while(($file=readdir($handle))!==false) { if($file !="." && $file !="..") { $fileFrom=$dirFrom.DIRECTORY_SEPARATOR.$file; $fileTo=$dirTO.DIRECTORY_SEPARATOR.$file; if(is_dir($fileFrom)) { copydir($fileFrom,$fileTo); }else{ copy($fileFrom,$fileTo); $filecount++; } } } closedir($handle); } copydir(mail,mailbak); echo "共拷贝".$filecount."文件,共拷贝目录".$dircount."个";
6, calculate program execution time
7. Determine whether the date format is correct
Copy after login
8.DeleteDirectory
$file删除成功
"; }else{ echo "文件 $file删除失败
"; } } } } } closedir($handle); if(rmdir($pathName)) { $dircount++; echo "目录 $pathName删除成功
"; }else{ echo "目录 $pathName删除失败
"; } } } deleteDir($file); echo "共删除".$filecount."文件,共删除目录".$dircount."个"; ?>
9. Submission cannot be empty
10.jsAutomatically jump to the specified page after n seconds
自动n秒后跳转到指定页面儿 2011-08-12 16:44:00
11, Calendar
'; $html .= ''; $html .= ' '; $html .= '上个月 '; $html .= '' . $date['year'] . '-' . $date['mon'] . ' 今天 '; $html .= '下个月 '; $html .= ''; $html .= ' '; $arr_tpl = array(0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => ''); $date_arr = array(); $j = 0; for ($i = 0; $i < $end['mday']; $i++) { if (!isset($date_arr[$j])) { $date_arr[$j] = $arr_tpl; } $date_arr[$j][($i+$start['wday'])%7] = $i+1; if ($date_arr[$j][6]) { $j++; } } foreach ($date_arr as $value) { $html .= '星期日 '; $html .= '星期一 '; $html .= '星期二 '; $html .= '星期三 '; $html .= '星期四 '; $html .= '星期五 '; $html .= '星期六 '; $html .= ''; foreach ($value as $v) { if ($v>9) { $vvv=$v; }else{ $vvv="0".$v; } $datemm=$date['year'].'-'.$date['mon'].'-'.$vvv; if ($v) { if ($v == $date['mday']) { $html .= ' '; } $html .= ''; echo $html; ?>' . $vvv . ' '; } else { $html .= '
'.$datemm.'' . $vvv . ' '; } } else { $html .= '
'.$datemm.''; } } $html .= '
The above is the detailed content of Sample code sharing for implementing some small things in PHP. For more information, please follow other related articles on the PHP Chinese website!