【问题标题】:Class Group contains 1 abstract method and must therefore be declared abstract or implement the remaining methods类组包含 1 个抽象方法,因此必须声明为抽象或实现其余方法
【发布时间】:2017-03-20 07:39:29
【问题描述】:

你好,我有问题,

用我的代码,我不知道我修复这个代码是什么

错误

致命错误:类组包含 1 个抽象方法,因此必须在第 16 行的 D:\xampp\htdocs\tes\index.php 中声明为抽象方法或实现其余方法 (Aturan::cari)

这是我的代码

<?php 
    interface Aturan {
        public function cari($id);
    }
    trait Bantuan {
            public function ubah_ke_string_json($str){
                return NULL;
            }
    }
    abstract class Aturan_abstrak implements Aturan {
            use Bantuan;
    }
    class Group extends Aturan_abstrak {
        protected $grup;

        public function Group($grup) {
                $this->grup = $grup;
        }
    } 
    $grup = new Group(array(
                "C" => array("administrator"),
                "A" => array("operator","staff")
            ));

    echo $grup->cari("A");
?>

我很困惑,请帮帮我。

【问题讨论】:

    标签: php oop


    【解决方案1】:

    这个错误意味着,需要先实现一个或多个抽象方法。在您的情况下,方法 cari 未实现。

    请查看主题Class Abstraction 了解更多信息。

    【讨论】:

    • 请查看错误字符串:Class Group contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Aturan::cari) 更多信息请参见php.net/manual/en/language.oop5.abstract.php
    猜你喜欢
    • 1970-01-01
    • 2014-07-09
    • 1970-01-01
    • 1970-01-01
    • 2021-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多