You can see that laravel has many useful functions built in.
The characteristic of these functions is that they do not depend on a specific class
So how do we add a custom globally available helper function?
Recommended:laravel tutorial
There are three steps in total
The first step
Create a new file in the app directory
helpers.php
(In fact, it doesn’t matter where it is or what its name is, the key lies in the next step)
Second step
Add
in composer.json Step 3
composer dumpautoload
Ok
The principle is to load automatically. Please search for details.
Related recommendations, PHP video tutorial learning address://m.sbmmt.com/course/list/29/type/2.html
The above is the detailed content of laravel adds custom helper function. For more information, please follow other related articles on the PHP Chinese website!