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();
精彩评论