How to resolve this error: Argument 1 passed to Zend_Mail_Message::__construct() must be of the type array, none given
How to resolve this error: Argument 1 passed to Zend_Mail_Message::__construct() must be of the type array, none given
我在控制器中的代码:
`
public function filetransport()
{
set_time_limit(0);
$message = new Zend_Mail_Message();
$message->addTo('matthew@zend.com')
->addFrom('ralph.schindler@zend.com')
->setSubject('Greetings and Salutations!')
->setBody("Sorry, I'm going to be late today!");
// Setup File transport
$transport = new Zend_Mail_Transport_File();
$transport->setOptions(array(
'path' => 'data/mail/',
'callback' => function (Zend_Mail_Transport_File $transport) {
return 'Message_' . microtime(true) . '_' . mt_rand() . '.txt';
},
));
$transport->send($message);
}
创建 Zend_Mail_Message 的实例时抛出 error.The 错误是
Catchable fatal error: Argument 1 passed to Zend_Mail_Message::__construct()
must be of the type array, none given,
called in C:\xampp\htdocs\Zend-Mailer\application\controllers\IndexController.php on line 102
and defined in C:\xampp\htdocs\Zend-Mailer\library\Zend\Mail\Message.php on line 57
如果您对此有任何想法,请告诉我......!
根据 Zend documentation Zend_Mail_Message
接受一个参数作为参数。您没有传递任何参数。这就是您收到此错误的原因。
__construct(array $params)
In addition to the parameters of Zend_Mail_Part::__construct() this
constructor supports:
- file filename or file handle of a file with raw message content
- flags array with flags for message, keys are ignored, use constants defined in Zend_Mail_Storage
Inherited_from \Zend_Mail_Part::__construct()
Zend_Mail_Part supports different sources for content. The possible
params are:
- handler a instance of Zend_Mail_Storage_Abstract for late fetch
- id number of message for handler
- raw raw content with header and body as string
- headers headers as array (name => value) or string, if a content part is found it's used as toplines
- noToplines ignore content found after headers in param 'headers'
- content content as string
这意味着,正如错误所说,您在构造函数中缺少 params
数组。
我在控制器中的代码: `
public function filetransport()
{
set_time_limit(0);
$message = new Zend_Mail_Message();
$message->addTo('matthew@zend.com')
->addFrom('ralph.schindler@zend.com')
->setSubject('Greetings and Salutations!')
->setBody("Sorry, I'm going to be late today!");
// Setup File transport
$transport = new Zend_Mail_Transport_File();
$transport->setOptions(array(
'path' => 'data/mail/',
'callback' => function (Zend_Mail_Transport_File $transport) {
return 'Message_' . microtime(true) . '_' . mt_rand() . '.txt';
},
));
$transport->send($message);
}
创建 Zend_Mail_Message 的实例时抛出 error.The 错误是
Catchable fatal error: Argument 1 passed to Zend_Mail_Message::__construct()
must be of the type array, none given,
called in C:\xampp\htdocs\Zend-Mailer\application\controllers\IndexController.php on line 102
and defined in C:\xampp\htdocs\Zend-Mailer\library\Zend\Mail\Message.php on line 57
如果您对此有任何想法,请告诉我......!
根据 Zend documentation Zend_Mail_Message
接受一个参数作为参数。您没有传递任何参数。这就是您收到此错误的原因。
__construct(array $params)
In addition to the parameters of Zend_Mail_Part::__construct() this constructor supports:
- file filename or file handle of a file with raw message content
- flags array with flags for message, keys are ignored, use constants defined in Zend_Mail_Storage Inherited_from \Zend_Mail_Part::__construct()
Zend_Mail_Part supports different sources for content. The possible params are:
- handler a instance of Zend_Mail_Storage_Abstract for late fetch
- id number of message for handler
- raw raw content with header and body as string
- headers headers as array (name => value) or string, if a content part is found it's used as toplines
- noToplines ignore content found after headers in param 'headers'
- content content as string
这意味着,正如错误所说,您在构造函数中缺少 params
数组。