致命错误:在第67行的/var/www/bugreporting.php中调用未定义的方法选项:: getCategoriesbug()

时间:2016-07-16 14:20:18

标签: php mysql apache

从我的apache日志中获取此完整错误(与标题相同):

PHP致命错误:在第67行的/var/www/bugreporting.php中调用未定义的方法选项:: getCategoriesbug()

bugreporting.php:

                <div class="form-group">
                    <label class="col-sm-2 control-label"><?= lang('category', 'Category'); ?></label>
                        <div class="col-sm-10">
                            <select class="selectpicker" data-style="btn-prom" name="pkg_category" style="padding-left: 8px;">
                                <?php 
                                $id = $_GET['id'];
                                if($id == '1'){
                                echo options::getCategoriesbug($id);
                            }?>
                            </select>
                        </div>
                </div>

和functions.php:

function getCategoriesbug($p, $db, $name, $res, $id){

global $db;
global $name;
global $res;
global $id;

$res = $db->getAll("SELECT * FROM bugcategories");
if ($res) {

    $ret = '';
    foreach ($res as $row) {
        $id2 = $row['id'];
        $name = $row['name'];


    }

    return $ret;
        require('../bugreporting.php');
}

}

如果有人知道问题的原因是什么,我会感谢一些帮助,因为此时我已经尝试修复它超过一个小时。

1 个答案:

答案 0 :(得分:0)

您的函数getCategoriesbug似乎未包含在名为options的类中 然后,调用这个简单函数的正确方法是:

echo getCategoriesbug($id);

如果函数getCategoriesbug是一个名为options的类中包含的方法(此处未显示),则表示方法的定义不正确。它应该是:

class options {

   static function getCategoriesbug($p, $db, $name, $res, $id) {
       // some code here
   }

   // maybe more methods here
}

文档:
- class
- static keyword