簡體   English   中英

PHP-為什么會出現此錯誤? 調用未定義的函數

[英]PHP - Why am I getting this error? Call to undefined function

我是php的新手,如果這很la腳,對不起。

我有一個具有兩個私有函數的簡單類。 由於某些原因,當我嘗試調用_sendInvalidEmailNotice()我收到一條錯誤消息,指出該函數未定義。

我究竟做錯了什么?

class Mail extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this - > load - > helper('email');
    }

    function _sendMessage($message) {
        send_email('name@gmail.com', 'Test Email', $message);
        $success = array('success' = > 'Mail Sent');
        echo json_encode($success);
    }

    function _sendInvalidEmailNotice() {
        $errorMessage = array('error' = > 'Invalid Email Address');
        echo json_encode($errorMessage);
    }

    public
    function sendMail($returnAddress, $message) {
        if (valid_email($returnAddress)) {
            _sendMessage($message);
        } else {
            _sendInvalidEmailNotice();
        }
    }


}

您需要添加上下文。

$this->_sendInvalidEmailNotice();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM