【发布时间】:2018-05-16 10:20:37
【问题描述】:
我正在使用我的命令行来执行类中的方法。但是我不断收到以下消息:
Error: Call to undefined function test() in Command line code on line 1
这是我的类和方法:
class DatasetTest
{
public function test()
{
echo ""worked";
}
}
这是我的命令行命令:
$ php -r 'require "DatasetTest.php"; test();'
我也试过了:
$ php -r 'require "DatasetTest.php"; $this->test();'
但收到以下消息;
Error: Using $this when not in object context in Command line code on line 1
【问题讨论】:
-
echo ""worked- 额外报价
标签: php command-line