PHP development, the call method is to pass the array parameters good or pass the object good?

Source: Internet
Author: User
Keywords Php
When you write C # before, the pass-through parameter is used by the object.
Now to PHP, found that most of the people are using an array of parameters, the array will cause later to see the code does not know what values are stored in the array.
Daniel, do you use arrays to pass parameters or to pass parameters with objects?

Reply content:

When you write C # before, the pass-through parameter is used by the object.
Now to PHP, found that most of the people are using an array of parameters, the array will cause later to see the code does not know what values are stored in the array.
Daniel, do you use arrays to pass parameters or to pass parameters with objects?

To see what you actually use, the array passes the value copy, and the object passes the reference.

Now PHP is more and more like Java, the more professional approach is best to replace the array with the collection class, so that the control of the data is more flexible, and the use of the collection class for code hints is very friendly. PHP allows you to use ambiguous variable types, but it is not suitable for complex projects, and it is difficult to understand the element types in the array.

The following is the collection class implemented in 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.