• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Load function, not view

At the end of a controller, instead of loading a view, is it possible to load a function? I know you can redirect to a function, but that doesn't allow you to carry $data ... does it?


yes you can load a function, if the functions in the same controller, you dont have to load a view at all.


Ah, excellent.

I've got another related problem. I want to pass a varible to the function I'm going to be loading. So I place it where you've put $param1.

I gather I have to then, in the function I'm loading, put function index($param1). When I do that, I get an spit up on my page regarding that parameter.

Any ideas?

Oh, think I got it. Had to set the parameter in the index function to be FALSE by default.

class Test extends Controller {
  function test() {
  function fish($var1="Nobody") {
    $var2 = "likes fish";
  function anotherfunc($var1,$var2)
    echo $var1." ".$var2;

Not sure I understand your question so I shall do a quick example see above..
it defaults to "Nobody likes fish"

if you call it with:


it will display "Wilma likes fish"

[edit]sorry missed your reply, glad you got it working

Cheers gtech, that actually helped a great deal. My problem was I was trying to pass two parameters to my Index function, by in the function they were being passed from only one of the variables was actually being declared.

Thanks again!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.