Get the App
SLTechnology News&Howtos  ›  Development  › 

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

Shulou Source: shulou.com Published: 2022-06-03 20:10:41 10月05日 Update

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!

Tags: Functions articles items notes contents variables versions questions one sentence not much prototypes parameters just suffixes most actual actually manuals files file names Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker vpn OPPO Reno Shulou Information MySQL