函數賦值給變量的操做:$_YZM=get(); 這樣就能夠很好的解釋哪些全局變量,超全局變量那些php
前者固定位數分割,後者以分隔符分割?web
strrev()
strlen()
number_format()
md5()
str_shuffle()
數組
explode()
implode()
join()
str_split();
函數
substr()
加密
strpos()
strrpos($str,'w')
url
str_replace()
spa
mb_substr($str,0,7,"utf-8");
code
dirname();
basename();
pathinfo();
parse_url();
parse_str();orm
1 <?php 2 3 $str='123456'; 4 5 echo strrev($str); 6 ?>
1 <?php 2 3 $str='1234567890128'; 4 5 echo number_format($str,0,'',','); 6 ?>
1 <?php 2 3 $str='1234567890128'; 4 5 6 function nf($str,$var){ 7 $str=strrev($str); 8 9 $arr=str_split($str,3); 10 11 $str2=join($var,$arr); 12 13 return strrev($str2); 14 } 15 16 echo nf($str,','); 17 ?>
1 <?php 2 3 $str='xiaojin456'; 4 5 echo md5($str); 6 7 ?>
1 <?php 2 3 $str='0123456789abcdefghijklnmopqrstuvwxyzABCDEFGHIJKLNMOPQRSTUVWXYZ'; 4 5 echo substr(str_shuffle($str),0,4); 6 7 ?>
1 <?php 2 3 $str='0123456789abcdefghijklnmopqrstuvwxyzABCDEFGHIJKLNMOPQRSTUVWXYZ'; 4 5 echo substr($str,-4); 6 7 ?>
1 <?php 2 $str='/www/myshop/web/index.php'; 3 4 $pos=strrpos($str,'/')+1; 5 6 echo substr($str,$pos); 7 ?>
1 <?php 2 $str='/www/myshop/web/index.php'; 3 4 $pos=strrpos($str,'/'); 5 6 echo substr($str,0,$pos); 7 ?>
1 <?php 2 $str='/www/myshop/web/index.php'; 3 4 echo str_replace('web/','',$str); 5 ?>
1 <?php 2 $str='/www/myshop/web/index.php'; 3 4 echo basename($str); 5 ?>
1 <?php 2 $str='/www/myshop/web/index.php'; 3 4 echo dirname($str); 5 ?>
1 <?php 2 $str='/myshop/web/index.php'; 3 4 $arr=pathinfo($str); 5 6 echo "<pre>"; 7 print_r($arr); 8 echo "</pre>"; 9 ?>
1 <?php 2 $str='http://www.yzmedu.com/myshop/web/index.php?id=10&name=user1'; 3 4 $arr=parse_url($str); 5 6 echo "<pre>"; 7 print_r($arr); 8 echo "</pre>"; 9 ?>
1 <?php 2 3 function get(){ 4 $query=$_SERVER['QUERY_STRING']; 5 6 $arr2=explode('&',$query); 7 8 foreach($arr2 as $val){ 9 $arr3=explode('=',$val); 10 $arr4[$arr3[0]]=$arr3[1]; 11 } 12 13 return $arr4; 14 } 15 16 $_YZM=get(); 17 18 echo "<pre>"; 19 print_r($_YZM); 20 echo "</pre>"; 21 ?>
1 <?php 2 $query='id=10&name=user1&age=20'; 3 parse_str($query,$arr); 4 5 echo "<pre>"; 6 print_r($arr); 7 echo "</pre>"; 8 ?>