Nick's Blog

PHP基础之变量(Variable)

变量(Variable):

  1. 变量必须已字母或者下划线开始

  1. 但是变量可以包含数字,字母和下划线

  1. 变量是区分大小写的

$webname = “www.901it.com.“;

$Webname = 123456;

$webName = “901it.com”;

  1. 同样的变量名是可以override之前的变量

举例:

$var = “901itcom”;

If (empty($var)){

echo “There is no variable.”

}else{

echo $var;

}

 

if(isset($_POST[‘test’])){

$test = $_POST[‘test’];

echo $test;

} else {

//do nothing

}

<a href=”002.php?webname=901itcom&uname=uname”>Click to Submit</a>

<form action = “” method = “post”>

<input type = “text” name = “test”>

<input type = “submit” value = “submit”>

</form>

  1. PHP中的值均可以再php.ini中查找,例如 upload_max_filesize[2m] < post_max_size[8m] < memory_limit[128m]

  1. 传值和传址举例:

$test = “901itcom”;

$test1 = &$test;  //传址

$test1 = “901it”;

echo $test;

OUTPUT:

901it

 

$test = “901itcom”;

$test1 = $test; //传值

$test1 = “901it”;

echo $test;

OUTPUT:

901itcom