In PHP development, is it better to call the method to pass array parameters or to pass objects?

Source: Internet
Author: User
When C # was previously written, all the passing parameters were using objects. Now it is converted to PHP, and it is found that most people use Arrays for passing parameters. If arrays are used, the code will not know what values are stored in the array. Can you tell me whether to use arrays to pass parameters or objects to PASS Parameters in the project? When C # was previously written, all the passing parameters were using objects.
Now it is converted to PHP, and it is found that most people use Arrays for passing parameters. If arrays are used, the code will not know what values are stored in the array.
Can you tell me whether to use arrays to pass parameters or objects to PASS Parameters in the project?

Reply content:

When C # was previously written, all the passing parameters were using objects.
Now it is converted to PHP, and it is found that most people use Arrays for passing parameters. If arrays are used, the code will not know what values are stored in the array.
Can you tell me whether to use arrays to pass parameters or objects to PASS Parameters in the project?

As you actually use it, the array transmits a copy of the value, and the object transmits a reference.

Now PHP is more and more like JAVA. It is better to use the collection class to replace the array in a professional way. This will make data control more flexible and the collection class is friendly to code prompts. PHP allows you to use variable types that are not clear, but is not suitable for complex projects. It is difficult to understand element types in arrays.

The following Collection classes are implemented using PHP:
Http://www.jb51.net/article/38848.htm

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.