Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How laravel creates functions

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "laravel how to create functions", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to create functions in laravel" this article.

Laravel create function method: 1, create Common folder in app directory; 2, create file custom function file; 3, write custom function method; 4, register custom function file; 5, call custom function.

This article operating environment: windows7 system, Laravel5.2 version, DELL G3 computer.

How does laravel create a function?

Laravel creates a custom function:

The current version of laravel is 5.2.*

1, create a Common folder in the app directory

2. Create custom function files such as helpers,php in the folder Common you just created

3. Write custom function methods in custom function files, such as:

If (! function_exists ('p')) {function p ($data) {echo "; print_r ($data); echo";}}

4. Register the function file you just customized in the autoload.php file in the bootstrap directory in the root directory

If (file_exists (DIR. '/.. / app/Common/helpers.php') {require DIR. '/.. / app/Common/helpers.php';}

5, you can now call your custom function anywhere in the project

These are all the contents of the article "how to create functions in laravel". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report