Blogger Information
Blog 2
fans 0
comment 1
visits 1117
Related recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php语法基础
守护你的姿态的博客
Original
504 people have browsed it

//设置php页面编码

header("Content-Type:text/html; charset=gb2312");

 

//数组的使用

<?php

$arr = array("123","321", "34435");

echo $arr[1];

echo "<br>";


$arr1 = array("key1" => "456","key2" => "89",4 => "45");

echo $arr1[key2];

echo "<br>";

 

$arr2 = array(23,34,1,2,54);

sort($arr2);//自动从小到大进行排列

print_r($arr2);


echo "<br>";

print_r($arr1);

?>

 

//使用list提取数组

<?php

$array = array("PHP", "MySql", "Apache");

list($php, $mysql, $apache) = $array;

echo "$php+$mysql+$apache<br>";



function test()

{

$value[] = "php";

$value[] = "mysql";

$value[] = "apache";

return $value;

}

list($php,$mysql,$apache) = test();

echo "$php*$mysql*$apache";

?>

 

//引用赋值,与全局,局部变量

<?php

$str1 = "eduask";

$str2 = "shanghai";

echo $str2."<br>";

$str2 = &$str1;//引用赋值

echo $str2."<br>";

$str1 = "eduask beijing";

echo $str2."<br>";

$str2 = "shanghai eduask";

echo $str1."<br>";



function test()

{

//$str1 = "In the function str1"; //局部变量

echo $str1."<br>";

}


test();

echo $str1."<br>";//全局变量


?>

 

//变量中,单引号和双引号的区别(不解释,解释)

 

<?php

$str="123";

echo '$str';

echo "$str";

?>

 

 

//isset(变量),判断是否设置了值

if(isset($name))

 

 

 

 

//加载(包含)外部php文件

include_once("外部文件");

 

 

 

 

 

 

 


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post