开发者

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

I am new to php, so sorry if this is lame.

I have a simple class that has two private functions. For some reason when I try to call _sendInvalidEmailNotice() I get an error stating that the function is undefined.

What am I doing wrong?

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();
        }
    }


}


You need to add context.

$this->_sendInvalidEmailNotice();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜