Blogger Information
Blog 6
fans 0
comment 0
visits 3773
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php1117作业
开吉尔软件
Original
662 people have browsed it

PHP1117作业

1.总结php打印输出方式并举例,php变量类型有哪些?举例说明;
2.传值赋值与引用赋值的不同点?


1.php打印输出方式并举例

echo 可以输出1个或者1个以上的字符串,echo后面有无()都可以。
print 只能输出一个字符器,并且有返回值为1,速度没有echo快。
print_r 输出数组
var_dump()输出详细信息

echo 输出

  1. echo 'Hello world';

print 输出

  1. print 'Hello';

print_r输出

  1. $arr =['How are you',99.9,true];
  2. print_r($arr);

/*
结果是:

Array
(
[0] => How are you
[1] => 99.9
[2] => 1
)

*/

var_dump()输出

  1. $arr =['How are you',99.9,true];
  2. var_dump($arr);

/*
结果是:

array(3) {
[0]=>
string(11) “How are you”
[1]=>
float(99.9)
[2]=>
bool(true)
}

*/

2.php变量类型有哪些?举例说明

变量有8种类型,分别是:
标量(字符串型,整型int,浮点型float,布尔型bool)
复合型(数组array 对象object)
特殊型 资源resourse 和 NULL

  1. $str = 'how are you?';
  2. $int = 100;
  3. $float = 99.99;
  4. $bl = true;
  5. $arr = [1,2,3];
  6. class stu {
  7. name = "miejue";
  8. gender = "female";
  9. age =30;
  10. function tutor() {
  11. echo 'miejue is a tutor';
  12. }

3.传值赋值与引用赋值的不同点?

传值赋值 例如:$a = 1 ; $b = $a;

引用赋值:例如:$a = &$b;

即变量$a和$b都指向了内存中的同一个存储变量的地址。

Correcting teacher:灭绝师太灭绝师太

Correction status:qualified

Teacher's comments:
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
1 comments
灭绝师太 2020-11-20 13:32:08
前两天的课程作业,就是知识点总结,目的是记住并且会用就可以了~总结的还可以再详细点,以后拿出来翻翻~
1 floor
Author's latest blog post