Home  >  Article  >  Backend Development  >  php学习之变量的使用_php基础

php学习之变量的使用_php基础

WBOY
WBOYOriginal
2016-05-17 09:19:05848browse
复制代码 代码如下:

//引用
$one="test";
two=&$one;//相当于传地址,两个变量指向一个地址

//动态变量
$one="######";
$two="one";
$three="two";

echo $three."
";//输出"two"
echo $$three."
";//输出"one"
echo $$$three."
";//输出"######"

//php中有8个类型
//4种标量: int integer
// bool boolean
// float,double,real
// string
//2种复合类型: array
// object
//2种特殊类型: 资源类型 resource
// 空类型 null


//整数的声明
$int=10; //十进制声明
$int=045;//八进制声明
$int=0xff;//十六进制声明
$float=3.14E+5;//科学计数法
$float=3.14E-5;

//一下都是false的情况
$bool=false;
$bool=0;
$bool=0.000;
$bool=null;
$bool="";
$bool=" ";
$bool="0";
$bool=array();

//字符串的声明
//1.单引号和双引号都可以声明字符串
//2.声明的字符串没有长度限制
//3.在双引号的字符串中,既可以直接解析变量,又可以直接使用转义字符(可以转义单引号本身,也可以转义转义字符"\")
//4.在单引号的字符串中,不可以直接解析变量,也不可以使用转义字符
//5.在双引号中不能再使用双引号,在单引号中不能再使用单引号
//6.最好使用单引号,
$str='aaaaa';
$str="aaaa";
//定界符声明字符串,大量字符串
//test是自定义的一个字符串,后面不能有任何字符,空格也不可以
//也要以test这个自定义的字符串结束,结束前不能有任何字符
$str=this write content......
test;
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn