php基础知识点

1.<!doctype html>

<html>
<body>

<?php

$x="Hello world";

 echo $x; 

echo "<br>";

$x='Hello world';

echo $x;

?>

</body>

</html>

2.var_dump()会返回变量的数据类型和值

<?php

$x=5985;

var_dump($x);

echo "<br>";

 

$x=-345;

 

var_dump($x);

 

echo "<br>";

$x=0x8C;

var_dump($x);

echo "<br>";

$x=047;

var_dump($x);

?>

运行结果:

int(5985) 
int(-345) 
int(140) 
int(39)

3.<?php

$car=array("Volvo","BMW","SAAB");

var_dump($car);

?>

运行结果:

array(3) { [0]=> string(5) "Volvo" [1]=> string(3) "BMW" [2]=> string(4) "SAAB" }

4.php对象

<?php

class Car

{

var $color;

function Car($color="green")

{

$this->color=$color;
}

function what_color()

{

return $this->color;
}
}

function print_vars($obj)

{

foreach(get_object_var($obj) as $prop=>$val) {

echo "\t $prop = $val\n";

      }
}

$herrbie=new Car("white");

echo "\herbie:Properties\n";

print_vars($herbie);

 ?>

 

 

 

 

 

posted @ 2017-10-10 15:35  江上玉坠  阅读(214)  评论(0编辑  收藏  举报