Analysis of precautions for passing reference of php functions, php function _ PHP Tutorial

Source: Internet
Author: User
Analysis of precautions for passing a value in a php function. Php function reference transfer notes analysis, this article describes the php function reference transfer notes. For your reference, the details are as follows: Analysis of precautions for passing Stri php function values, and analysis of php functions

This article describes the reference and transfer notes for php functions. We will share this with you for your reference. The details are as follows:

Strict standards: Only variables shocould be passed by reference

There is such a sentence on the Internet:

This problem may occur in php5.3 or later versions. It should also be related to the php configuration. if you split this sentence into two sentences, there will be no problem.Because the array_walk parameter is passed by reference, by default, more than 5.3 can only pass specific variables, but cannot return values through the function.Of course, you can also modify error_reporting = E_ALL | E_STRICT in php. ini, but this does not comply with the rules.

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

Why is this restriction imposed by the higher version?

Let me 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. it is passed by reference.

Changed:

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

You can.

In fact, it only generates a warning. Not a fatal error. The normal result is. For example, the suffix of the file name is normal.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.