Home > Backend Development > PHP Tutorial > laravel 下函数内访问函数外变量

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:37:02
Original
1191 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:
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
Latest Issues
Composer cannot install laravel
From 1970-01-01 08:00:00
0
0
0
Laravel Space/laravel-backup cannot be installed
From 1970-01-01 08:00:00
0
0
0
Laravel 5.1 Login laravel comes with it No more
From 1970-01-01 08:00:00
0
0
0
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template