Home >Backend Development >PHP Tutorial >PHP basic learning the use of variables

PHP basic learning the use of variables

高洛峰
高洛峰Original
2016-11-30 10:26:20940browse

The code is as follows:
//Quote
$one="test";
two=&$one;//Equivalent to passing an address, two variables point to one address

//Dynamic variable
$one ="######";
$two="one";
$three="two";

echo $three."
";//Output "two"
echo $$three ."
";//Output "one"
echo $$$three."
";//Output "######"

//There are 8 types in php
//4 types of scalars: int integer
// bool boolean
// float, double, real
// string
//2 types of composite types: array
// object
//2 special types: resource type resource
// Empty type null


//Declaration of integer
$int=10; //Declaration of decimal
$int=045;//Declaration of octal
$int=0xff;//Declaration of hexadecimal
$float= 3.14E+5;//Scientific notation
$float=3.14E-5;

//When all are false
$bool=false;
$bool=0;
$bool=0.000;
$bool =null;
$bool="";
$bool=" ";
$bool="0";
$bool=array();

//Declaration of string
//1. Single quotes and double quotes Quotation marks can be used to declare strings
//2. There is no length limit for the declared string
//3. In double-quoted strings, variables can be parsed directly, and escape characters can be used directly (single quotes can be escaped itself, the escape character "") can also be escaped
//4. In a single-quoted string, variables cannot be parsed directly, nor can escape characters be used
//5. It cannot be used in double quotes Double quotes, single quotes can no longer be used within single quotes
//6. It is best to use single quotes,
$str='aaaaa';
$str="aaaa";
//Delimiter declaration string, a large number String
//test is a custom string, there cannot be any characters after it, and spaces are not allowed
//It must also end with the custom string test, and there cannot be any characters before the end
$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