I need to use some functions in CI controller.
For example:
class Main extends Controller
{
function index()
{
function foo1(){}
function foo2(){}
}
}
But I get an error. How to determine these functions?
I need to use some functions in CI controller.
For example:
class Main extends Controller
{
function index()
{
function foo1(){}
function foo2(){}
}
}
But I get an error. How to determine these functions?
If you use the function declaration syntax inside another function, the inside function will end up in the current namespace (or the global namepsace if no namespace was declared)
consider this example:
Class Foo {
public function bar() {
function foo(){
print 'in foo';
}
}
}
$f = new Foo();
$f->bar(); // you have to call this before invoking the foo() function, prior this point its nonexistent
foo(); // will print 'in foo'