在php中,假设在test.php
中有一个名为" test_class "的类,有两个方法:method_1
和method_2
。
这是我的test.php
文件:
class test_class
{
function method_1
{ ....... }
function method_2
{ ....... }
}
现在,使用其他php文件中的"exec"命令,我想只运行test_class中的method_1。
我想知道这是如何实现的?
你可以这样做:
include_once 'test.php'; // correct path if needed
$test = new test_class();
// call method1
$test->method_1();
你看过说明书了吗?
exec
不是用来调用方法的,它是用来:
exec -执行外部程序