laravel 下函数内访问函数外变量

WBOY
Release: 2016-06-06 20:37:02
Original
1122 people have browsed it

<code>    function something($p)
    {
        Mail::send('view', array(
            "email" => $p->email
        ), function ( $message) 
        {
            $message->to($p->email, $p->name)->subject('hello');
        })
    }
</code>
Copy after login
Copy after login

怎么在laravel框架下Mail::send的第三个参数闭包内访问闭包外的变量?

回复内容:

<code>    function something($p)
    {
        Mail::send('view', array(
            "email" => $p->email
        ), function ( $message) 
        {
            $message->to($p->email, $p->name)->subject('hello');
        })
    }
</code>
Copy after login
Copy after login

怎么在laravel框架下Mail::send的第三个参数闭包内访问闭包外的变量?

function () use ($var) {

http://php.net/manual/en/functions.anonymous.php#example-186

如何在 Laravel 中使用 SMTP 发送邮件(适用于 163、QQ、Gmail 等)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template