Laravel What is the difference between use
a file inside a calss
and use
a file outside a class
?
For example, we often see a bunch of use
after namespace
, these use
are outside class
,
some use
is in class
again, what is the difference between the two?
Example: HttpControllersAuthRegisterController.php
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Illuminate\Auth\Events\Registered;
class RegisterController extends Controller
{
use RegistersUsers;
//...
}
高洛峰2017-05-16 16:49:46
Outside the class is the imported namespace, inside the class is the trait, and after the function is the variable capture.
Documentation:
Use namespace: alias/import
Trait
Anonymous function