从html页面调用php函数

时间:2016-06-27 15:41:07

标签: php html

我试图从一个html页面(dueligibletoenroll_view.php)调用一个简单的php函数(SetEligibleToEnrollTerms())。此页面的路径是\ cs \ views \ staff \ advisees \ dueligibletoenroll_view.php。

下面你可以看到我已经尝试了很多方法从JEE19开始#39开始调用它。

<?php 
$this->load->view('common/heading', array(
    'heading'       => 'Eligible to Enroll',
    'show_back_btn' => true
)) 

/*JEE19 begin*/
//use \cs\classes\CampusSolutions\API\Staff\Advisees\Advisees.php;
//include Advisees.php;
//require_once('Advisees.php');
/*JEE19 end*/
?>
<section>
...
...
                            <input style="margin-right:20px;" type="checkbox" data-role="none" data-message="<?php echo $message ?>" class="check-elig-enrl" id="<?php echo $term->acad_career . '/' . $term->acad_prog . '/' . $term->strm ?>" name="<?php echo $key ?>" value="<?php echo $term->acad_prog ?>" checked="checked" <?php echo $disabled ?>/>

<?php echo SetEligibleToEnrollTerms() ?>

具有该函数的脚本的路径是cs \ classes CampusSolutions \ API \职员\ Advisees.php

这就是函数的作用:

       public function SetEligibleToEnrollTerms() {
        echo "here3";
}

我尝试调用该函数的所有不同方式都导致了类似于下面描述代码无法调用它的错误。有谁知道我怎么称呼这个功能?

Fatal error: Call to undefined function SetEligibleToEnrollTerms() in /srv/highpoint/cs/views/staff/advisees/dueligibletoenroll_view.php on line 70 

1 个答案:

答案 0 :(得分:0)

您是否已初始化该课程并正确调用该方法?

require $_SERVER['DOCUMENT_ROOT'].'path_to_parent_class.php';
require $_SERVER['DOCUMENT_ROOT'].'path_to_class.php';

$oAdvisees = new Advisees();

$oAdvisees->SetEligibleToEnrollTerms();