[英]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.