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);
?>
相关文档:
include实现国际化
将index.php进行翻译:
Index内容
1. Index
2. About us
我们可以将index.php设置为一个翻译模版,所有出现字符的地方,都定义为变量,如1,2部分设置为翻译的变量$menu_index, $menu_aboutus.
......
<?php
/*
$Id: PHPZip.php
*/
class PHPZip {
var $datasec = array();
var $ctrl_dir = array();
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
var $old_offset = 0;
& ......
无意间看到以前发的帖子.回忆起那些PHP的日日夜夜
http://www.phpfans.net/ask/discuss2/343326196.html
<?
class gzg//钙中钙类
{
var $x;//属性
function gzg()//构造函数,默认不吃钙中钙
&n ......
有时候nginx,apache,mysql,php编译完了想看看编译参数可以用以下方法
nginx编译参数:
#/usr/local/nginx/sbin/nginx -V
CODE:
nginx version: nginx/0.6.32
built by gcc 4.1.2 20071124 (Red Hat 4.1.2-42)
configure arguments: --user=www --group=www --prefix=/usr/local/nginx/ --with-http_stub_status_mo ......
1、数组的申请和使用:
$array=array(array(2,324,34));
echo $array[0][1];
直接申请使用:
$student[0][0]="我";
$student[0][1]="是";
$student[1][0]="谁";
$student[1][1]="维";
echo $student[1][0];
2、遍历: ......