php检验email:
function checkEmail($email) { $pregEmail = "/([a-z0-9]*[-_.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[.][a-z]{2,3}([.][a-z]{2})?/i"; return preg_match($pregEmail,$email); }
php截取汉字:
function GBsubstr($string, $start, $length) { if(strlen($string)>$length){ $str=null; $len=$start+$length; for($i=$start;$i<$len;$i++){ if(ord(substr($string,$i,1))>0xa0){ $str.=substr($string,$i,2); $i++; }else{ $str.=substr($string,$i,1); } } return $str.'…'; }else{ return $string; } }
php heredoc: //一种结构,利于php中输出html
http://www.nowamagic.net/php/php_UseHeredocOutputHtml.php //heredoc的相关链接
<?php if ( isset($_SESSION['user']) ) { echo <<< eod <div class="left"> <dl class="style2"> <dt class="top0">1</dt> <dt class="top0">2</dt> <dt class="top0">3</dt> <dt class="top0">4</dt> <dt class="top0">5</dt> <dt class="top0">6</dt> </dl> </div> eod; } else { echo <<< eod2 <div style="text-indent:2em; margin-top:10px">您还没有登录,请登录后再进行表格相关操作。</div> eod2; } ?>
相关链接:
http://jingyan.baidu.com/article/a65957f49e30a424e77f9b45.html //百度经验里的面试题
http://www.cnblogs.com/luckylp/archive/2012/04/16/2451402.html //php原生mysql 事务处理
http://blog.csdn.net/iloveyin/article/details/8045528 //百度校园招聘