首页 > PHP教程

php zend 配置,数据库加,模板引擎设置

今天我们来讲一下关于php mvc模板的zend使用方法与配置实例,这是一款从zend加载 config文件到加载数据库 getinstance()方法用来获取前端控制器实例 加载smarty模板插件等简单的配置方法。
*/
 //指明引用文件的路径
    set_include_path('.' .
    path_separator . './libary/'.           //指定zend所在目录
    path_separator . './application/models/'. //指定model所在目录
    path_separator . './libary/smarty/'.   
    path_separator . get_include_path());

阅读全文

php $HTTP_COOKIE_VARS 实例投票资料限制

if ($http_cookie_vars["vote"]) {
 echo "<script>alert('您已经投过票了,请不要重复投票');history.back();</script>";
 exit;
}
$vcount=$_post["vcount"];
$lld=$_post["jump"];
$tys=$_post["tys"];
if (!$vcount) {
 echo "<script>alert('您还没有选择任何投票项目');history.back();</script>";
 exit;
}
$db=@mysql_connect("localhost","root","root") or die("数据库教程连接失败");
mysql_select_db("vote",$db);
if ($vcount&&$lld) {
 if ($tys=="1") {
  $sql="update vote set vcount=vcount+1 where id=$vcount";
  $result=mysql_query($sql,$db);
  setcookie("vote","vote",time()+3600);
  echo "<script>alert('投票成功!');location.href='vote.php?id=$lld';</script>";
 }
 else {
  for ($i=0;$i<sizeof($vcount);$i++) {
   $sql1="update vote set vcount=vcount+1 where id=$vcount[$i]";
   $result1=mysql_query($sql1,$db);
  }
  setcookie("vote","vote",time()+3600);
  echo "<script>alert('投票成功!');location.href='vote.php?id=$lld';</script>";
 }
}

阅读全文

php分页代码的原理

//为了避免重复包含文件而造成错误,加了判断函数是否存在的条件:
$page = $_get[page];
if(!function_exists(pageft)){
//定义函数pageft(),三个参数的含义为:
//$totle:信息总数;
//$displaypg:每页显示信息数,这里设置为默认是20;
//http://pic3.phprm.com/2010/09/11/$url.jpg:分页导航中的链接,除了加入不同的查询信息"page"外的部分都与这个url相同。
//   默认值本该设为本页url(即$_server["request_uri"]),但设置默认值的右边只能为常量,所以该默认值设为空字符串,在函数内部再设置为本页url。
function pageft($totle,$displaypg=20,$url=''){

阅读全文

php文件上传程序(支持缩略图)(1/2)

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>上传文件程序</title>
<style type="text/css教程">
*{
 font-size:12px;
 margin:0; padding:0;
}
a:link,a:visited{
 text-decoration:none;
 color: #393
}
a:hover{
 text-decoration:underline;
 color:#0033cc
}
input.text{
 border:1px solid #ccc;height:22px;line-height:22px;padding-left:5px;background:#fff;width:274px;
}
input.button{
 background:#fff url(http://pic4.phprm.com/2010/09/11/button.jpg);border:1px solid #9ea9c5;padding:2px 2px 0px 2px;margin-left:4px; margin-right:4px;
}
</style>
<script language=网页特效>
function check()
{
 var strfilename=document.myform.upfile.value;
 if (strfilename=="")
 {
     alert("请选择要上传的文件");
  document.myform.upfile.focus();
     return false;
   }
}
</script>
</head>

阅读全文

php mysql 数据库备份程序

?>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link type="text/css教程" rel="stylesheet" href="common/control.css">
<script type="text/网页特效" language="javascript" src="common/admin.otable.js"></script>
<script type="text/javascript" language="javascript" src="common/include.func.js"></script>
<title>数据管理</title>
<style type="text/css">
span {padding-left:8px;}
</style>
</head>

阅读全文

正则表达式匹配字母 汉字 空格

验证由26个英文字母组成的字符串:^[a-za-z]+$
验证由26个大写英文字母组成的字符串:^[a-z]+$
验证由26个小写英文字母组成的字符串:^[a-z]+$
验证由数字和26个英文字母组成的字符串:^[a-za-z0-9]+$
验证由数字、26个英文字母或者下划线组成的字符串:^w+$
验证用户密码:^[a-za-z]w{5,17}$ 正确格式为:以字母开头,长度在6-18之间,只能包含字符、数字和下划线。
验证是否含有 ^%&',;=?$" 等字符:[^%&',;=?$"]+
验证汉字:^[u4e00-u9fa5],{0,}$
验证email地址:^w+[-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$
验证interneturl:^http://([w-]+.)+[w-]+(/[w-./?%&=]*)?$ ;^[a-za-z]+://(w+(-w+)*)(.(w+(-w+)*))*(?s*)?$
验证电话号码:^((d{3,4})|d{3,4}-)?d{7,8}$:--正确格式为:xxxx-xxxxxxx,xxxx-xxxxxxxx,xxx-xxxxxxx,xxx-xxxxxxxx,xxxxxxx,xxxxxxxx。
验证身份证号(15位或18位数字):^d{15}|d{}18$
验证一年的12个月:^(0?[1-9]|1[0-2])$ 正确格式为:"01"-"09"和"1""12"
验证一个月的31天:^((0?[1-9])|((1|2)[0-9])|30|31)$    正确格式为:01、09和1、31。

阅读全文

php 正则表达式验证数字

非负浮点数(正浮点数 + 0):^d+(.d+)?$
正浮点数   ^(([0-9]+.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*.[0-9]+)|([0-9]*[1-9][0-9]*))$
非正浮点数(负浮点数 + 0) ^((-d+(.d+)?)|(0+(.0+)?))$
负浮点数  ^(-(([0-9]+.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*.[0-9]+)|([0-9]*[1-9][0-9]*)))$
浮点数  ^(-?d+)(.d+)?

阅读全文