Question about passing parameters in the module in the MVC framework

Source: Internet
Author: User
1. I recently noticed this kind of phenomenon in the development process. Usually, the CURD operation on the data is put into the module. just call it in the controller and input the corresponding parameters! I personally dislike this way of passing parameters through the form parameter! I was wondering if we could receive parameters in the module... 1. I noticed this phenomenon during the development process recently. The CURD operations on the data will be placed in the module., In Controller callEnter the corresponding parameters! I personally dislike this way of passing parameters through the form parameter! I was wondering if we could process parameters in the module? In this way, the module can be called anywhere else? Which of the following parameters are required for this module!

Most people write
// Module public function login ($ userName, $ passWord, $ validCode) {$ param ['username'] = $ userName; $ param ['password'] = $ passWord; $ param ['validcode'] = $ validCode; return $ param;} // controller public function test () {$ userName = $ _ POST ['username']; $ passWord = $ _ POST ['password']; $ validCode = $ _ POST ['validcode']; $ this-> login ($ userName, $ passWord, $ validCode ));}
My writing method
// Module public function login () {$ param ['username'] =$ _ POST ('Username '); $ param ['password'] =_ _ POST ('password'); $ param ['validcode'] =$ _ POST ('validcode'); return $ param ;} // controller public function test () {$ this-> login ();}

But now most people use the first method! I admit that there may be problems when running the command line! But I think I will choose to encapsulate a function for the sake of concise code to adapt my writing to various scenarios.

Reply content:

1. The recent development process noticed such a phenomenon, usuallyThe CURD operations on the data will be placed in the module., InController callEnter the corresponding parameters! I personally dislike this way of passing parameters through the form parameter! I was wondering if we could process parameters in the module? In this way, the module can be called anywhere else? Which of the following parameters are required for this module!

Most people write
// Module public function login ($ userName, $ passWord, $ validCode) {$ param ['username'] = $ userName; $ param ['password'] = $ passWord; $ param ['validcode'] = $ validCode; return $ param;} // controller public function test () {$ userName = $ _ POST ['username']; $ passWord = $ _ POST ['password']; $ validCode = $ _ POST ['validcode']; $ this-> login ($ userName, $ passWord, $ validCode ));}
My writing method
// Module public function login () {$ param ['username'] =$ _ POST ('Username '); $ param ['password'] =_ _ POST ('password'); $ param ['validcode'] =$ _ POST ('validcode'); return $ param ;} // controller public function test () {$ this-> login ();}

But now most people use the first method! I admit that there may be problems when running the command line! But I think I will choose to encapsulate a function for the sake of concise code to adapt my writing to various scenarios.

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.