<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019-12-02
* Time: 21:33
*/
//echo phpinfo();
//PHP语法标记
/*/<?php echo “php语法标记”; ?>
//php注释
/* */
//
//变量
//$a = 10;
//$a=””;
//empty($a);
//isset($a);
//unset($a);
//!empty($a);//存在且不为空;
//$a=25;
//$b=&$a;
////unset $b;
////echo $a;
//var_dump($a);//查看数据类型
//$a=”adbc”;
//$abc=”kaslfklj$a”;
//$abcd=’kaslfklj$a’;
//echo $abcd;
//array();
//gettype();
//settype();
//define(“AAA”,100);
//echo AAA;
//true;
//true; false; true false;
//$a=10;
//++$a;
//echo $a;
//and &&
//or ||
//$a = 1;
//1? 22:33; 三元
//if();
//if(){
//
//}else{
//
//}
//if(){
//
//}else if(){
//
//}else if(){
//
//}
//switch(){
// case:1
// echo 1;
// break;
// case:2
// echo 2;
// break;
// case:3
// echo 3;
// break;
//}
//$a=1;
//while($a <10){
// echo “值$a<br>”;
// $a++;
//}
//$tb=0;
//while($tb<10){
// echo “<tr bgcolor=’red’></tr>”;
// $tb++;
//
//}
//<!–<table>–>
//$tr=0;
//while($tr<10){
// echo “<tr bgcolor=’red’>”;
// $td=0;
// while($td<10){
// echo “<td>”;
// echo “111”;
// echo “</td>”;
// $td++;
// }
// echo “</tr>”;
// $tr++;
//}
//<!–</table>–>
//for($b=0;$b<10;$b++){
// echo $b.”<br>”;
//}
//function xh(){
// //函数体
// return 1;
//}
//function fC(){
// echo 1;
// return;
//}
//
//function fca(){
// echo 2;
//}
//
//function fcb($a,$b,$c){
// echo 3;
//}
//global; static; $GLOBALS[];
//$a = 0;
//function fc(){
// echo $a; //函数无法使用外边的全局变量
//}
//function fc(){
// global $a; //
// echo $a; //增加了,global,函数可以使用外边的全局变量
//}
//function fc(){
// echo $GLOBALS[‘a’]; //全局的数组访问函数外的局部变量
//}
//function fc(){
// global $a;
// static $a=0;
// echo $a;
// $a++;
//}
//echo fc();
//echo fc();
//echo fc();
//function fc(&$a){
// $a=200;
//}
//$b=100;
//echo fc($b);
//echo $b;
//function fc($a,$b=2,$c=3){
// echo “{$a},{$b},{$c}”;
//}
//fc(1);
//function aa(){
// echo “aa”;
//}
//
//function bb(){
// echo “bb”;
//}
//
//function cc(){
// echo “cc”;
//}
//
//$result = “aa”;
//echo $result();
//function dg($n){
// echo $n;
// if($n>0){
// echo dg($n-1);
// }else{
// echo “<++++>”;
// }
// echo $n;
//}
//dg(15);
//$ar = array(“111″,”222″,”333”);
//array (size=3)
// 0 => string ‘111’ (length=3)
// 1 => string ‘222’ (length=3)
// 2 => string ‘333’ (length=3)
//Array ( [0] => 111 [1] => 222 [2] => 333 )
//$ara=array();
//$ara[“0″]=”a”;
//$ara[“1″]=”b”;
//$ara[“2″]=”c”;
//array (size=3)
// 0 => string ‘a’ (length=1)
// 1 => string ‘b’ (length=1)
// 2 => string ‘c’ (length=1)
//Array ( [0] => a [1] => b [2] => c )
//$arb[‘ID’]=”123456″;
//$arb[‘name’]=”wulei”;
//$arb[‘hod’]=”30″;
//array (size=2)
// ‘ID’ => string ‘123456’ (length=6)
// ‘name’ => string ‘wulei’ (length=5)
//Array ( [ID] => 123456 [name] => wulei [hod] => 30 )
//var_dump($arb);
//print_r($arb);
$cwar=array(
“市场部”=>array(),
“业务部”=>array(),
“财务部”=>array()
);
//array (size=3)
// ‘市场部’ =>
// array (size=0)
// empty
// ‘业务部’ =>
// array (size=0)
// empty
// ‘财务部’ =>
// array (size=0)
// empty
//Array ( [市场部] => Array ( ) [业务部] => Array ( ) [财务部] => Array ( ) )
//var_dump($cwar);
//print_r($cwar);
//
//$ar = array(“1″,”wulei”,”35″,”hanzu”);
//var_dump($ar);
//print_r($ar);
//array (size=4)
// 0 => string ‘1’ (length=1)
// 1 => string ‘wulei’ (length=5)
// 2 => string ’35’ (length=2)
// 3 => string ‘hanzu’ (length=5)
//Array ( [0] => 1 [1] => wulei [2] => 35 [3] => hanzu )
//$ar = array(“1″,”wulei”,”35″,”hanzu”);
//
// echo “<table>”;
// echo “<tr>”;
//
// for($i=0; $i<count($ar); $i++) {
// echo “<td>{$ar[$i]}</td>”;
// }
//
// echo “</tr>”;
// echo “</table>”;
//$ar = array(“id”=>”1″,”xm”=>”wulei”,”nl”=>”35″,”mz”=>”hanzu”);
//$kv = each($ar);
//var_dump($kv);
//print_r($kv);
//array (size=4)
// 1 => string ‘1’ (length=1)
// ‘value’ => string ‘1’ (length=1)
// 0 => int 0
// ‘key’ => int 0
//Array ( [1] => 1 [value] => 1 [0] => 0 [key] => 0 )
//list($k,$v)=$ar;
//echo $k.”<br>”;
//echo $v.”<br>”;
//list($k,$v)=each($ar);
//echo “$k=>$v”;
//while(list($k,$v)=each($ar)){
// echo “$k=>$v”.”<br>”;
//}
//$_SERVER;
//$_GET;
//$_POST;
//$_COOKIE;
//$_SESSION;
//$GLOBALS;
//$_FILES;
//$_REQUEST;
$ar = array(“id”=>”1″,”xm”=>”wulei”,”nl”=>”35″,”mz”=>”hanzu”);
$aar = array(“id”=>”1″,”xm”=>”wulei”,”nl”=>”35″,”mz”=>”hanzu”,”xm”=>”wulei”);
$arv=array_values($ar);
$ark=array_keys($ar);
//var_dump($arv);
//var_dump($ark);
$sar=in_array(“wulei”,$ar);
//if($sar){
// echo “值存在”;
//}else{
// echo “值不存在”;
//}
$iar=isset($ar[‘xm’]);
$ear=array_key_exists(“wulei”,$ar);
//var_dump($iar);//true
//var_dump($ear);//false
$far=array_flip($ar);//键和值,互换
//var_dump($far);
$rar=array_reverse($ar);//数组头和尾反转
//array (size=4)
// ‘mz’ => string ‘hanzu’ (length=5)
// ‘nl’ => string ’35’ (length=2)
// ‘xm’ => string ‘wulei’ (length=5)
// ‘id’ => string ‘1’ (length=1)
//var_dump($rar);
//echo count($ar);
//var_dump(array_count_values($ar));
//array (size=4)
// 1 => int 1
// ‘wulei’ => int 1
// 35 => int 1
// ‘hanzu’ => int 1
//$uaar=array_unique($aar);
//var_dump($uaar);