php中常用函数技巧
1.随机字符序列生成函数:
<?php
//用于验证码序列生成等..
function random($length) {
$hash = '';
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$max = strlen($chars)-1;
$length=4;//长度自行设定
mt_srand((double)microtime() * 1000000);
for($i = 0; $i < $length; $i++){
$hash .= $chars[mt_rand(0, $max)];
}
return $hash;
}
//测试输出:
//echo random(4);
?>
相关文档:
global定义一个全局变量,这个全局变量不是应用整个网站,而是应用与当前页面(包括require和include文件)文件。
$aa="test";
function test()
{
global $aa;
echo $aa;
}
test(); //print test
函数内定义的变量函数外可以调用,在函数外定义的的变量函数内不能使用。
gl ......
1、PHP发送中文、Ajax接收
只需在php顶部加入一句:
header('Content-type: text/html;charset=GB2312');
xmlHttp会正确解析其中的中文。
2、Ajax发送中文、PHP接收
这个比较复杂:
Ajax中先用encodeURIComponent对要提交的中文进行编码
PHP中:
$GB2312string=iconv( ‘UTF-8′, ‘gb2312//I ......
本教程采用的是xampp自带的tomcat插件来完成整合的,所以,要想完成整合,第一步不需下载xampp,及其tomcat插件~
1.打开xampp官网 点此xampp官网打开
&n ......
无意间看到以前发的帖子.回忆起那些PHP的日日夜夜
http://www.phpfans.net/ask/discuss2/343326196.html
<?
class gzg//钙中钙类
{
var $x;//属性
function gzg()//构造函数,默认不吃钙中钙
&n ......
PHP Security for Deployers
If you're a Developer
READ THIS and then work with your SysAdmins to step through any and all the layers of security designed to protect your apps.
Example:
Traffic must first pass through a SPI firewall (ensure that ONLY necessary ports/protocols are permitted; en ......