Pixrael Posted April 21, 2017 Posted April 21, 2017 Hi, I'm getting a Call to undefined function error when I try to call a function (eg. like the sample renderNavTree) that is in the _func.php file from a file (header.inc.php) included in _main.php. I already check the namespace, and that all the files are including correctly. All is OK If I make the call from _main.php, but it doesn't work if I do it from the file that is included. What foolish mistake am I do??
Zeka Posted April 21, 2017 Posted April 21, 2017 @Pixrael Do you have _init.php or similar that set in ? $config->prependTemplateFile = '_init.php'; Could you try to include your _func.php there?
Pixrael Posted April 21, 2017 Author Posted April 21, 2017 Yes, if I call the function from _main.php ( <?php renderNavTree(); ?> or <?php echo renderNavTree(); ?> ) all work as expected, but when call the same function from an external file that is included in _main.php I get that error.. even TracyDebugger don't see this error... let me clarify the context: _func.php <-- the function is declared here _init.php <-- here load the _func.php _main.php <-- call the function from here = ok ..here is include _header.inc.php includes _header.inc.php <-- call the function = error All the content from _header is include in main correctly when I don't call the function, so all seems to be fine until I use any function from _func.php file I tried to include _func.php directly inside _header.php but don't work... but for me this no make sense because the functions was already loaded from _init.php in the PW workflow
Zeka Posted April 21, 2017 Posted April 21, 2017 Are you sure about namespaces? Do you declare them in _header.inc.php? 3
Pixrael Posted April 21, 2017 Author Posted April 21, 2017 OK, that's all.. the famous namespace.. I try that before (because it's a common problem here in the forum) but I receive this error "Compile Error: Namespace declaration statement has to be the very first statement or after any declare call in the script" perhaps I let some whitespace before the <?php ... so for my record: the namespace statement should be declared in every every every php file that I use in my project? Thanks Zeka!!
SamC Posted July 24, 2017 Posted July 24, 2017 On 21/04/2017 at 9:02 PM, Zeka said: Are you sure about namespaces? Do you declare them in _header.inc.php? Exact problem I just had with an undefined function, damn namespace! Keep forgetting it. Thanks @Zeka
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now