Welcome Guest, Not a member yet? Register   Sign In
Function to call functions...? (newbie question)
#1

[eluser]Juan Velandia[/eluser]
It´s Ok to call a function from another function in the same controller?

Code:
function reload(){
echo $something;
function index();
}

It doesn´t seem to work for me, do you have Ideas?

Thanks in advance!
#2

[eluser]bretticus[/eluser]
It's not exactly apparent what you are trying to accomplish here. Are you trying to call a another method from the controller class? Or are you trying to use a function that will be used by the method that currently encapsulates it (anonymous function?)

If it's the former, it's a simple $this->other_method() call (prepend an underscore to prevent this method from being routable.)

If it's the latter, unless you are using PHP version 5.3.x use the intrisic PHP function: create_function.
#3

[eluser]Juan Velandia[/eluser]
Hi Bretticus, thanks for the tip, Im going to check PHP function: create_function. perhaps I´ve been trying to solve this thing in the wrong way. Best Regards!
#4

[eluser]billmce[/eluser]
[quote author="bretticus" date="1269046349"]It's not exactly apparent what you are trying to accomplish here. Are you trying to call a another method from the controller class? Or are you trying to use a function that will be used by the method that currently encapsulates it (anonymous function?)

If it's the former, it's a simple $this->other_method() call (prepend an underscore to prevent this method from being routable.)

If it's the latter, unless you are using PHP version 5.3.x use the intrisic PHP function: create_function.[/quote]

When you say 'routable' ... what (in English) do you mean? (I did google this but 'routable' and 'php' turns up a lot of mapping routines).
#5

[eluser]bretticus[/eluser]
[quote author="billmce" date="1269052209"]
When you say 'routable' ... what (in English) do you mean? (I did google this but 'routable' and 'php' turns up a lot of mapping routines).[/quote]

I was referring to "private" functions in controllers

Which states...

Quote:In some cases you may want certain functions hidden from public access. To make a function private, simply add an underscore as the name prefix and it will not be served via a URL request.

Yes, my concept of "routable" gets lost in translation for sure.




Theme © iAndrew 2016 - Forum software by © MyBB