php - A certain function can be implemented using a function. Is it necessary to use a class to implement it?
滿天的星座
滿天的星座 2017-05-31 10:33:09
0
10
645

I use PHP. Most of the functions in the project I am writing now are encapsulated into functions. When needed, just require and then pass parameters to call the function. I don’t know if this will be bad. , do we still need to use classes to implement it?

Take the homepage of the segmentfault website as an example (the homepage displays some questions). If you want me to write (using MVC), I will first write a function getQuestion(parameter) that specifically gets the questions, and then add it to the homepage model (class ) in the require function, and then call this function by passing parameters. After obtaining the data, render it to the View.
I always feel that "require this function and then call it to get the data" is not good to write, but I don't know how to write it well. I hope you can give me some advice

滿天的星座
滿天的星座

reply all(10)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!