• 实例首页
  • 自学教程
  • IT工具箱
xxxxxxxxxx
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<title>PHP 变量函数 实例 - 自学教程(runoops.com)</title>
6
</head>
7
<body>
8
​
9
<?php
10
class Foo
11
{
12
    function Variable()
13
    {
14
        $name = 'Bar';
15
        $this->$name(); // 调用 Bar() 方法
16
    }
17
​
18
    function Bar()
19
    {
20
        echo "This is Bar";
21
    }
22
}
23
​
24
$foo = new Foo();
25
$funcname = "Variable";
26
$foo->$funcname();  // 调用 $foo->Variable()
27
​
28
?>
29
​
30
</body>
31
​
32
</html>

© 2023 自学教程   runoops.com All Rights Reserved. 备案号:闽ICP备19010956号-1