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

What are the considerations for reference passing of values passed by php functions?

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you what php function reference transfer points for attention, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

The details are as follows:

Strict standards: Only variables should be passed by reference

The information found on the Internet has this sentence:

This problem will occur in the above version of php5.3, which should also be related to the configuration of php. As long as you split this sentence into two sentences, there will be no problem. Because the parameters of array_walk are passed by reference, the above defaults can only pass specific variables and cannot return values through functions. Of course, you can also modify error_reporting = E_ALL | E_STRICT in php.ini, but this does not conform to the specification after all.

$suffix = array_pop (explode (".", $file_name))

Why is the higher version so limited?

I went to see the function prototype in the manual:

Mixed array_pop (array & $array) bool array_walk (array & $array, callable $funcname [, mixed $userdata = NULL])

The & symbol specifies that the variable is passed in and is passed by reference.

Change to:

$file_name_arr = explode (".", $file_name); $suffix = array_pop ($file_name_arr)

That's fine.

In fact, it was just a warning. It's not a fatal mistake. The normal result is available. For example, it is normal to get the suffix of the file name here.

The above is all the contents of the article "what are the points for attention in the reference transfer of php functions?" 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