Welcome Guest, Not a member yet? Register   Sign In
Controller runs its constructor again after POST
#11

[eluser]bolts25[/eluser]
Wow! That is not what I expected.

So every time I do a post pointing to a controller function the controller is instantiated and the constructor is run.

That will require a rethink.

Thanks.

#12

[eluser]CroNiX[/eluser]
That's how php classes work. Any time a class is instantiated it's constructor runs if there is one.
#13

[eluser]bolts25[/eluser]
Yeah I know that, but it had already been instantiated and the constructor had already run. From the post I was just calling a function in the class. I did not expect the constructor to run again because of this call.
#14

[eluser]CroNiX[/eluser]
It's a separate call. Each call to a URL will instantiate a controller, generate output and then it's done. The first call you are displaying a form. Then you submit a form to a controller, even if it's the same one, which is a separate call.
#15

[eluser]bolts25[/eluser]
OK. Thanks for that. I had no idea this was the way it worked.




Theme © iAndrew 2016 - Forum software by © MyBB