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.