Welcome Guest, Not a member yet? Register   Sign In
Confusing name of view()-method in the tutorial
#2

Actually the method view() does not "show" anything. The showing action takes place much later after the controller is done executing. This happens without developer intervention.

To be pedantic, show() is a method of the loader class not the controller. So $this->load->view("someview"); is utilizing the "load" property of the controller ($this) to call the loader method "view" which will "include" the file "someview". Views are not classes in the CodeIgniter framework. They are php files that contain html and potentially template language markup. Because they are not classes views have no methods. But they might contain functions and frequently include php code along with the markup.

Defining a controller method called show() or showPage() that makes the call to view() would be a good instructional project for your students.

On the other hand, changing the name would be entertaining mostly because of the s__ storm is would cause due to the broken backward compatibility.
Reply


Messages In This Thread
RE: Confusing name of view()-method in the tutorial - by dave friend - 04-11-2017, 12:23 PM



Theme © iAndrew 2016 - Forum software by © MyBB