php常用正则表达式

//手机号正则
‘preg_phone’ => ‘/^((13[0-9])|147|(15[0-35-9])|180|181|182|(18[5-9]))[0-9]{8}$/’,

//验证手机号是否注册过
if(!preg_match(C(‘preg_phone’),$info[‘phone’])){
$this->error(‘手机号格式不正确’);
}

//身份证正则
‘indentity_card15’ => ‘/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/’,
‘indentity_card18’ => ‘/^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/’,

//验证身份证信息
if(count($_POST[‘indentity_card’]) == 15){ //15位身份证
$preg_match = preg_match(C(‘indentity_card15’),$_POST[‘indentity_card’]);
}else{ //18位身份证
$preg_match = preg_match(C(‘indentity_card18’),$_POST[‘indentity_card’]);
}
if(!$preg_match){
$this->error(“请输入正确的身份证号码”);
}

thinkphp 模板标签

if   elseif    else

<if condition=”$trms[‘type’] eq 1″>selected</if>

<if condition=”$trms[‘keyword’] neq null”>value=”{$trms.keyword}”</if>

{$vo[‘sex’]==1?’男’:’女’}

 

<if condition=”$item[‘parent_id’] eq 0″>
<a title=”<{$item.cate_name}>” target=”_blank” href=”<{:U(‘tuan/index’,array(‘cat’=>$item[‘cate_id’]))}>”><{$item[‘cate_name’]}></a>
<else/>
<a title=”<{$item.cate_name}>” target=”_blank” href=”<{:U(‘tuan/index’,array(‘cat’=>$item[‘parent_id’],’cate_id’=>$item[‘cate_id’]))}>”><{$item[‘cate_name’]}></a>
</if>

foreach   循环

<foreach name=”tuancates” item=”item”>
<eq name=”item.is_hot” value=”1″>
<php>$i++;if($i<10){</php>
<if condition=”$item[‘parent_id’] eq 0″>
<a title=”<{$item.cate_name}>” target=”_blank” href=”<{:U(‘tuan/index’,array(‘cat’=>$item[‘cate_id’]))}>”><{$item[‘cate_name’]}></a>
<else/>
<a title=”<{$item.cate_name}>” target=”_blank” href=”<{:U(‘tuan/index’,array(‘cat’=>$item[‘parent_id’],’cate_id’=>$item[‘cate_id’]))}>”><{$item[‘cate_name’]}></a>
</if>
<php>}</php>
</eq>
</foreach>

 

时间

{$vo.register_time|date=”y-m-d H:i”,###}

 

url

<a class=”btn” href=”{:U(‘Member/memberlist’,array(‘type’=>6))}”>会员</a>

 

wamp 添加本地虚拟机

1.httpd.conf

#LoadModule rewrite_module modules/mod_rewrite.so #去掉
#Include conf/extra/httpd-vhosts.conf #去掉

2.http-vhosts.conf

D:\php\wamp\bin\apache\apache2.4.9\conf\extra该目录下

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot “c:/Apache2/docs/dummy-host.example.com”
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog “logs/dummy-host.example.com-error.log”
CustomLog “logs/dummy-host.example.com-access.log” common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot “c:/Apache2/docs/dummy-host2.example.com”
ServerName dummy-host2.example.com
ErrorLog “logs/dummy-host2.example.com-error.log”
CustomLog “logs/dummy-host2.example.com-access.log” common
</VirtualHost>

3.hosts

127.0.0.1 localhost
127.0.0.1 admin.yuka.com