-
商量 PHP 接见把握器与运算符优先级
添加时间:2013-7-10 点击量:PHP中关于接见把握器和运算符优先级的内容分享。
<?php
/
php接见把握器的例子
edit by www.jbxue.com
/
class Foo
{
private ¥name = hdj;
public function getName(){
return ¥this->name;
}
}
class Bar extends Foo
{
public ¥name = deeka;
}
¥bar = new Bar;
var_dump(¥bar->name);
var_dump(¥bar->getName());
?>有关php中的接见把握
对属性或办法的接见把握,是经由过程在前面添加关键字 public、protected 或 private 来实现的。由 public 所定义的类成员可以在任何处所被接见;由 protected 所定义的类成员则可以被其地点类的子类和父类接见(当然,该成员地点的类也可以接见);而由 private 定义的类成员则只能被其地点类接见。
1 <?php
2 /
3 php接见把握 与 运算符优先级
4 by www.jbxue.com
5 /
6 ¥a = 3;
7 ¥b = 6;
8 if(¥a = 5 || ¥b = 7){
9 echo ¥b.<br />;
10 ¥a++;
11 ¥b++;
12 }
13 var_dump(¥a, ¥b);
14 echo <br /> ¥a = (5 || ¥b = 7);
15 echo <hr />;
16 ¥a = 3;
17 ¥b = 6;
18 ¥c = 1;
19 if(¥a = 5 || ¥b = 7 && ¥c = 10){
20 ¥a++;
21 ¥b++;
22 }
23 var_dump(¥a, ¥b,¥c);
24 echo <br /> && 比 || 高;
25 echo <hr />;
26 ¥a = 3;
27 ¥b = 6;
28 ¥c = 1;
29 if(¥a = 0 || ¥b = 7 && ¥c = 10){
30 ¥a++;
31 ¥b++;
32 }
33 var_dump(¥a, ¥b,¥c);
34 echo <br /> ;
35 echo <hr />;
36 class Foo {
37 private ¥name = hdj;
38 public function getName() {
39 return ¥this->name;
40 }
41 }
42
43 class Bar extends Foo {
44 public ¥name = deeka;
45 }
46
47 ¥bar = new Bar;
48 var_dump(¥bar->name);
49 var_dump(¥bar->getName());
50 ?>