All methods use array parameters. What are the drawbacks of this method in project development?

Source: Internet
Author: User
All methods use array parameters. What are the drawbacks of this method in project development? Php is a weak type language. in the project, if I define all the method portals as $ array, which of the following are the drawbacks of this function, such as functiontest ($ array ), it doesn't matter. it's just a form parameter ., I didn't see that framework was doing this. it doesn't mean that all the methods use array parameters. What are the drawbacks of doing so in project development?
Php is a weak type language. in the project, if I define all the method portals as $ array, which of the following are the drawbacks of this function, such as function test ($ array)

------ Solution --------------------
It doesn't matter. it's just a form parameter.
------ Solution --------------------
I didn't see that the framework was doing this. it doesn't mean this is not the case.

A function (method) usually requires a set of specific parameters.
In addition, this set of parameters can be checked during compilation to check whether the number of parameters is sufficient.
When you pass the parameter as an array, you need to check the validity and completeness of the parameter in the function body.
We have to say Disadvantages. This should be considered
------ Solution --------------------
Let's see how your function is written. Your function test ($ array) parameter is not necessarily an array. it depends on what data is passed during the call.
------ Solution --------------------
Error message not defined for variable
The rest depends on how your function is written.

In addition to array, you can use 'XXX, xxx, xxx, XXX', and $ xxxx to pass the parameter, but it is not necessary to break the problem into an array and then change the function.

Discussion

If arrays are used as parameters, but the validity and completeness of parameters are not checked in the function body, what problems will arise?

------ Solution --------------------
How do you write it is your business. As for the validity of the parameter, you also write it in the program. Also, you must transfer the array to the program based on the actual situation, no. net, isn't it. net parameters are all arrays ??? No.

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.