Get与Post
//POST if(isset( $_POST['add_gift'] )) { $game=trim( $_POST['game'] ); } //GET if(isset( $_GET['add_gift'] )) { $game=trim( $_GET['game'] ); }
foreach示例
foreach( $items as $item ){ echo $item; //一个元素 } foreach( $arr as $key => $value ){ echo $key; //键 echo $value; //值 }
格式字符串分装成变量
$arr = explode('|',"abc|123"); list($str1, $str2) = $arr;
echo $str1;
echo $str2;
数组的创建
$records=[]; //数组的初始化 $arr1=[ 'jxjz','dt2','fmz'] //一维数组创建 $arr2 =[ //二维数组创建 ['jxjz','剑啸九州'], ['dt2','大唐2'], ['fmz','伏魔者'] ]; array_push($arr1,"ddd"); //动态插入一维数组 array_push($arr2, [ "aaa","bbb" ]); //动态插入二维数组
SESSION
Session_Start(); if( !isset( $_SESSION['groups'] ) ){ $session = $_SESSION['groups'] ; }