I want to use MVC in my website.
I don’t know where should I use template (that can be included in a php page) and when should I use view (that is a function inside a class so we can echo it).
Please help me.
had to look that up didn’t know what that was.
found this page. if it can help while you wait for someone more experienced in this to answer!
why do you want to use mvc however? just curious.
D
I don’t know where should I use template (that can be included in a php page) and when should I use view (that is a function inside a class so we can echo it).
I’m guessing you just mean a function that echo’s something to the screen without having it’s own dedicated view?
Usually “Views” are the actual html pages that accept information from the Controller. What you may be thinking of is probably a service, such as a JSON response called by ajax somewhere, where you don’t need an actual view page to render any information. That would be the only time you should echo anything directly from the controller. Echoing HTML directly from the controller will quickly get messy and that’s just not what a controller is supposed to do.
What framework are you using? (if any)
If you’re not using any frameworks and are thinking about rolling your own, check out this video series. It might be able to help you clear up anything you’re having trouble with. I’d suggest watching it even if you were using a prebuilt MVC framework.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.