您的位置:首页 > 编程语言 > PHP开发

My study note of PHP language(IV)

2016-04-02 23:57 429 查看

Variable

What is the variable?

used to storage the value.

How to define the variable?

$var_name="苹果";
$n=10;


Naming rules for variable names

1.The variable name must be a letter or an underscore “_” at the beginning.

2.The variable must be named only by letters, numbers, and “_”, but also contains Chinese characters.

3.Variable names are not allowed to contain spaces.

4.Variable names in PHP are case sensitive.

PHP variable data type

8 primitive types are supported:

4 scalar types: boolean, interger, float, string.

2 compound types: array, object.

2 special types: resource, null.

We don not have to declare the data type of variables, PHP will automatically change it into the automantical data type.

$var_string = "hello world!";
var_dump($string);
$var_string = 312;
var_dump($string);


We can see the result:

string(12) “hello world!”

int(312)

The variable has been changed into interger type. automatically.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: