A
A
alexandrnevajno12018-01-27 07:31:24
PHP
alexandrnevajno1, 2018-01-27 07:31:24

MVC PHP - why is it undesirable to declare variables in View? Why is it necessary to declare it in the controller, and then pass it to the View?

Project on Kohana. It is more convenient for me to declare immediately in the View at the beginning of the file. No need to switch between two files - Controller and View. Why do you need to declare it in the controller? What is the approach of declaring variables in View fraught with?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Decadal, 2018-01-27
@Decadal

Because then throw away your controller, why do you need it?
The idea of ​​mvc is that you can replace your view that works with these variables with another view (perhaps even on the fly) - and it will work. This is how you remove the dependence of the view on the context

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question