Settings
|
Sign in
|
Sign up
Bar
Post
Home
>
Bar PHP
>
View post
Reply the post
|
View all
The author has
1
post.
PHP类方法中的静态变量原来是在所有类之间共享的!
Floor 1
巨大八爪鱼
11/25/15 11:42
<?php
class Apple {
public function show() {
static $number = 10;
echo "$number<br>";
$number++;
}
}
$app1 = new Apple();
$app1->show();
$app2 = new Apple();
$app2->show();
$app2->show();
?>
输出:
10
11
12
Content converter:
No conversion
Mainland
Taiwan
Hong Kong
Singapore
Reply the post
Content:
User:
You are currently anonymous.
Captcha:
Unclear? Try another one.