Home > Backend Development > PHP Tutorial > Analysis of matters needing attention when passing by reference in PHP function, PHP function_PHP tutorial

Analysis of matters needing attention when passing by reference in PHP function, PHP function_PHP tutorial

WBOY
Release: 2016-07-12 08:49:19
Original
905 people have browsed it

Analysis of the reference passing precautions for php function passing by value, php function

The examples in this article describe the reference passing precautions for php function passing by value. Share it with everyone for your reference, the details are as follows:

Strict standards: Only variables should be passed by reference

I found information on the Internet and there is this sentence:

This problem will occur in php5.3 and above versions. It 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, only specific variables can be passed by default in version 5.3 and above, and values ​​cannot be returned through functions. Of course you can also modify error_reporting = E_ALL | E_STRICT in php.ini, but this does not comply with the specification after all.

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

Copy after login

Why do higher versions have such restrictions?

I’ll look at the function prototype in the manual:

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

Copy after login
The

& symbol specifies the variable to be passed in, which is passed by reference.

changed to:

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

Copy after login

That’s it.

Actually, it just reports a warning. Not a fatal error. Normal results can be obtained. For example, it is normal to get the suffix of the file name here.

Readers who are interested in more PHP-related content can check out the special topics of this site: "Introduction Tutorial on PHP Object-Oriented Programming", "Summary of PHP Mathematical Operation Skills", "Summary of PHP Office Document Operation Skills (including word, excel, access, ppt)", "Complete PHP Array (Array) Operation Skills", "PHP Data Structure and Algorithm Tutorial", "php Programming Algorithm Summary", "php Regular Expression Usage Summary", and "php Common Database Operation Skills" Summary》

I hope this article will be helpful to everyone in PHP programming.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1138979.htmlTechArticleAnalysis of matters needing attention when passing by reference by value in php function, php function This article explains the reference passing by value by php function Things to note. Share it with everyone for your reference, the details are as follows: Stri...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template