Jump to content

MVC?


davej
 Share

Recommended Posts

I haven't gotten too far yet learning PHP, and the current beginner project I'm working on is a php page that submits a form to itself. It has one other php include page just for defining php functions. When the PHP is working it will have Javascript/AJAX added. Is that a completely "goofball" situation or is it usable? It certainly isn't MVC, so what is it? Thanks

Link to comment
Share on other sites

Submitting the form to itself is fine, depending on the situation. If you submit it to itself, and the user didn't fully fill it out (or filled it out incorrectly), you can use a few echo()s to prevent the user from having to fill the whole form out again. In my opinion, PHP functions should ALWAYS be in a separate file to be include()d at run time. It makes it a lot easier to reuse those functions in other projects, or even just other pages of the same project. "MVC" is not in my vocabulary, and Google isn't helping. What is "MVC"?

Link to comment
Share on other sites

MVC is "preferred architecture" that everyone tells you to use. I would have to admit that I don't yet have a complete grasp of what all it entails. I also don't know if it applies equally to all forms of server-side scripting. See... http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

Link to comment
Share on other sites

It's a programming paradigm. Not necessarily related to server-scripting at all, but to programming in general.
There is code which generates the visible pages. There is code which validates user input. There is code that processes user input probably accessing files and databases and using object classes and methods. There is code which spews the results back to visible pages. Does that cover the M, the V, and the C? Edited by davej
Link to comment
Share on other sites

There is code which validates user input. There is code that processes user input probably accessing files and databases and using object classes and methods. There is code which spews the results back to visible pages
http://www.tonymarst...controller.html Edited by birbal
Link to comment
Share on other sites

Nonetheless, PHP, basically, it is not an MVC architecture language(though you can develop PHP applications based on MVC)-it is a "template view language",meaning, no controllers in the loop, but only view and models.

Link to comment
Share on other sites

Nonetheless, PHP, basically, it is not an MVC architecture language(though you can develop PHP applications based on MVC)-it is a "template view language",meaning, no controllers in the loop, but only view and models.
So what constitutes a true "controller?"
Link to comment
Share on other sites

It's code the does a specific "job"-(it acts as the mediator between "views" and "models")i have never made an application based on MVC so i cannot giveyou an example-my knowledge is purely theoretical.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...