All methods use the array parameter, which is the disadvantage in project development
Source: Internet
Author: User
All methods use the array parameter, what are the drawbacks in project development?
PHP is a weakly typed language, and in a project, if I define all method portals as $array, what are the drawbacks, such as: function test ($array)
------Solution--------------------
It doesn't matter, it's just a formal argument.
------Solution--------------------
I don't see that frame doing this, it doesn't mean you can't do that.
Usually a function (method) that requires a specific set of parameters
And this set of parameters is to be able to check out the number of parameters in the compilation process is sufficient
When you pass the uniform as an array, you need to check the validity and completeness of the parameters in the function body.
Not to say the disadvantage, this should be counted as a
------Solution--------------------
See how your function is written. Your function test ($array) parameter is not necessarily an array, it depends on what data is passed when you call.
------Solution--------------------
Error message not defined by variable
The rest depends on how your function is written.
You can use the ' xxx,xxx,xxx,xxx ' in addition to the array, $xxxx pass it on, but it's not going to hurt the egg. Variable group function
Explore
What happens if you use an array as a parameter but do not check the validity and completeness of the parameters yourself in the function body?
------Solution--------------------
How do you write it is your business, as you say check the legality of the parameters is also you write in the program, there is why must be sent into the array, according to the actual situation, not. NET, is the. NET parameter an array??? No way
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.