What is the difference between using a file in a class and using a file outside a class in Laravel?
ringa_lee
ringa_lee 2017-05-16 16:47:46
0
1
480

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;
    
   //...

}
ringa_lee
ringa_lee

ringa_lee

reply all(1)
小葫芦

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!