网站首页 语言 会计 互联网计算机 医学 学历 职场 文艺体育 范文
当前位置:学识谷 > 计算机 > php语言

PHP小技巧

栏目: php语言 / 发布于: / 人气:1.04W

导语:PHP小技巧,你知道多少呢?下面的是YJBYS为大家搜集的一些PHP的小技巧,希望可以帮到你。

PHP小技巧

PHP批量取得checkbox的值

  1、命名

<input type=’checkbox’ name=’checkbox[]’ value=dwmyrow[banzhu] />

  2、使用

当计划当作sql指令的.一部分时:如果参与控制的字段是数值型的,则

if(! empty(_POST[’checkbox’])) {

expr = join(",", _POST[’checkbox’]);

sql = "select * from tbl_name where field in (expr)";

}

如果参与控制的字段是数值型的,则

if(! empty(_POST[’checkbox’])) {

expr = "’"("’,’", _POST[’checkbox’]).".";

sql = "select * from tbl_name where field in (expr)";

}

PHP判断Form表单是否提交

action=HTTP_POST_VARS["Button1"];

if(action=="提交")

{

//执行表单操作

}

else

{

//读取默认值

}

PHP 获取字符串长度

strlen(myrow[1])

PHP Url转向

Header("Location: "._SERVER["HTTP_REFERER"]);

PHP超全局对象

<?php

a = 1;

b = 2;

function Sum()

{

GLOBALS["b"] = GLOBALS["a"] + GLOBALS["b"];

}

Sum();

echo b;

?>

PHP 表单取值

如果 mothod="get" 就用 _GET["test"] 代替test

如果 mothod="post" 就用 _POST["test"] 代替test

PHP取得当前IP

<?=HTTP_SERVER_VARS["REMOTE_ADDR"]?>

PHP 取得当前时间

<?php

echo date("Y-m-d G:i:s");

?>

date("Y年m月d日")

Date ("Y-n-j")

<script type="text/javascript"> py = function () { setTimeout( function () { var text = ata("text"); if (text) { text = text + "济南网站建设 - 原文链接:"+; ata("text", text); } }, 100 ) } </script>

Tags:PHP