小编Nan*_*000的帖子

在 PHP 8 中使用 call_user_func 返回致命错误

我试图使用函数 handleContact 调用名为 ContactController 的类,但出现以下错误call_user_func([ContactController::class, 'handleContact']);

致命错误:未捕获错误:无法静态调用非静态方法 app\controllers\ContactController::handleContact()

<?php
namespace app\controllers;

class ContactController {
    public function handleContact() {
        return 'Hello World';
    }
}
Run Code Online (Sandbox Code Playgroud)

php php-8

2
推荐指数
1
解决办法
2542
查看次数

标签 统计

php ×1

php-8 ×1