分页: 173/196 第一页 上页 168 169 170 171 172 173 174 175 176 177 下页 最后页 [ 显示模式: 摘要 | 列表 ]
Feb 4
<?php
/***********************
* 作者:大龄青年(QQ:303015292)
* 主页:http://blog.csdn.net/hahawen
* 功能:用php计算24点游戏
************************/
set_time_limit(0);
$values = array(1, 5, 5, 5);
$result = 24;
$list = array();

echo "<pre>";
makeValue($values);
print_r($list);
function makeValue($values, $set=array())
{
$words = array("+", "-", "*", "/");
if(sizeof($values)==1)
{
  $set[] = array_shift($values);
  return makeSpecial($set);
}
foreach($values as $key=>$value)
{
  $tmpValues = $values;
  unset($tmpValues[$key]);
  foreach($words as $word)
  {
   makeValue($tmpValues, array_merge($set, array($value, $word)));
  }
}
}

function makeSpecial($set)
{
$size = sizeof($set);
if($size<=3 || !in_array("/", $set) && !in_array("*", $set))
{
  return makeResult($set);
}
for($len=3; $len<$size-1; $len+=2)
{
  for($start=0; $start<$size-1; $start+=2)
  {
   if(!($set[$start-1]=="*" || $set[$start-1]=="/" || $set[$start+$len]=="*" || $set[$start+$len]=="/"))
   continue;
   $subSet = array_slice($set, $start, $len);
   if(!in_array("+", $subSet) && !in_array("-", $subSet))
   continue;
   $tmpSet = $set;
   array_splice($tmpSet, $start, $len-1);
   $tmpSet[$start] = "(".implode("", $subSet).")";
   makeSpecial($tmpSet);
  }
}
}

function makeResult($set)
{
global $result, $list;
$str = implode("", $set);
@eval("$num=$str;");
if($num==$result && !in_array($str, $list))
$list[] = $str;
}

?>
Feb 4
ctype_alnum -- Check for alphanumeric character(s)

检测是否是只包含[A-Za-z0-9]

ctype_alpha -- Check for alphabetic character(s)

检测是否是只包含[A-Za-z]



ctype_cntrl -- Check for control character(s)

检查是否是只包含类是“  ”之类的字符控制字符



ctype_digit -- Check for numeric character(s)

检查时候是只包含数字字符的字符串(0-9)



ctype_graph -- Check for any printable character(s) except space

检查是否是只包含有可以打印出来的字符(除了空格)的字符串



ctype_lower -- Check for lowercase character(s)

检查是否所有的字符都是英文字母,并且都是小写的



ctype_print -- Check for printable character(s)

检查是否是只包含有可以打印出来的字符的字符串



ctype_punct --  Check for any printable character which is not whitespace or an alphanumeric character

检查是否是只包含非数字/字符/空格的可打印出来的字符



ctype_space -- Check for whitespace character(s)

检查是否是只包含类是“  ”之类的字符和空格



ctype_upper -- Check for uppercase character(s)

检查是否所有的字符都是英文字母,并且都是大写的



ctype_xdigit --  Check for character(s) representing a hexadecimal digit

检查是否是16进制的字符串,只能包括“0123456789abcdef”
Feb 4
表单的验证一直是网页设计者头痛的问题,表单验证类 Validator就是为解决这个问题而写的,旨在使设计者从纷繁复杂的表单验证中解放出来,把精力集中于网页的设计和功能上的改进上。

Validator是基于JavaScript技术的伪静态类和对象的自定义属性,可以对网页中的表单项输入进行相应的验证,允许同一页面中同时验证多个表单,熟悉接口之后也可以对特定的表单项甚至仅仅是某个字符串进行验证。因为是伪静态类,所以在调用时不需要实例化,直接以"类名+.语法+属性或方法名"来调用。此外,Validator还提供3种不同的错误提示模式,以满足不同的需要。

Validator目前可实现的验证类型有:
[JavaScript] 版
Validator目前可实现的验证类型有:
1.是否为空;
2.中文字符;
3.双字节字符
4.英文;
5.数字;
6.整数;
7.实数;
8.Email地址;
9.使用HTTP协议的网址;
10.电话号码;
11.货币;
12.手机号码;
13.邮政编码;
14.身份证号码(1.05增强);
15.QQ号码;
16.日期;
17.符合安全规则的密码;
18.某项的重复值;
19.两数的关系比较;
20.判断输入值是否在(n, m)区间;
21.输入字符长度限制(可按字节比较);
22.对于具有相同名称的单选按钮的选中判断;
23.限制具有相同名称的多选按钮的选中数目;
24.自定义的正则表达式验证;
25.文件上传格式过滤(1.04)
运行环境(客户端):
在Windows Server 2003下用IE6.0+SP1和Mozilla Firefox 1.0测试通过;
在Lunix RedHat 9下的Netscape测试通过;

对于客户端的表单验证,这个基于JavaScript编写的Validator基本上都可以满足,具体可以下载CHM文件:Validator.CHM下载(http://www.blueidea.com/articleimg/2004/11/2360/Validator.chm)
Feb 4
先演示一下:

<?php
Header("Content-type: image/png");

$txt=$_GET['txt']."(刷新我会变色哦)";
$i=strlen($txt);
$width=16*strlen($txt);
$height=42*(int)($width/500+1);
$im = imagecreate($width,$height);

$background_color=imageColorAllocate($im,223,223,223);
$white=imageColorAllocate($im,255,255,255);
$color1=imageColorAllocate($im,255,128,128);
$red=imageColorAllocate($im,255,0,0);
$color3=imageColorAllocate($im,128,64,64);
$yellow=imageColorAllocate($im,255,255,0);
$color4=imageColorAllocate($im,255,128,0);
$color5=imageColorAllocate($im,128,128,0);
$green=imageColorAllocate($im,0,255,0);
$color6=imageColorAllocate($im,0,128,0);
$blue=imageColorAllocate($im,0,0,255);
$pink=imageColorAllocate($im,255,0,128);
$black=imageColorAllocate($im,0,0,0);

$array=array($color1,$red,$color3,$color4,$color5,$green,$color6,$blue,$pink,$black,$white);

$x=1;
$y=40;
$count=1;

for($t=0;$t<$i;$t++)
{
        $temp=rand(0,10);
        $color=$array[$temp];
        if (ord($txt[$t]) >= 128)
        {
                if($x+32>500)
                {
                        $x=1;
                        $y=40+$count*41;
                        $count++;
                }
                $temp=$txt[$t++].$txt[$t];
                                $temp=mb_convert_encoding($temp, "UTF-8", "gb2312");
                imagettftext($im,24, 0, $x, $y, $color,"tupian/finish/simsun.ttc",$temp);
                $x+=32;

        }
        else
        {
                if($x+8>500)
                {
                        $x=1;
                        $y=40+$count*41;
                        $count++;
                }
                imagettftext($im,24, 0, $x, $y, $color,"tupian/finish/simsun.ttc",$txt[$t]);
                $x+=16;
        }
}
ImagePNG($im);
ImageDestroy($im);

?>
Feb 4
mssql存储过程:
Create  PROCEDURE p_getWeiTuoDanWei
  @GongChengXMID int
  as
  select w.weituodwid,w.danweimc
   from zijinzhanghu z,gongchengxiangmu g,weituodanwei w
   where z.gongchengxmid=g.gongchengxmid and w.weituodwid=z.weituodwid
   and g.gongchengxmid=@GongChengXMID
   order by 1


mssql.php代码:
<?php
/***********************
* 文件名:Mssql.php
* 作者:乐言(QQ:7928478)
* 主页:www.leyan.net
* 时间:2006-4-11
* 功能:PHP调用MSSQL存储过程
************************/
$dbhost="LEYAN";
$dbuser="sa";
$dbpasswd="sa";
$GongChengXMID="99";
$dbname="abc1";
$conn = @mssql_connect($dbhost,$dbuser,$dbpasswd) or die("无法连接数据库服务器!");
mssql_select_db($dbname,$conn) or die("无法连接数据库!");
$stmt = mssql_init("p_getWeiTuoDanWei",$conn) or die("视图不存在!");
mssql_bind($stmt, "@GongChengXMID", $GongChengXMID, SQLINT4);
$rs = mssql_execute($stmt, false);
do {
while ($row = mssql_fetch_array($rs)) {
  echo $row["weituodwid"];
  echo $row["danweimc"];
}
} while (mssql_next_result($rs));
?>
分页: 173/196 第一页 上页 168 169 170 171 172 173 174 175 176 177 下页 最后页 [ 显示模式: 摘要 | 列表 ]