Why doesn't the function call, although the file with the function seems to be connected?


Tell me why it does not work, error Call to undefined function.

Code file index.php

 * load helper functions
require_once '../kernel/helpers.php';

 * load the application routes
require_once '../config/routes.php';

in the file routes.php use the function from a file helpers.php.

I upload these files to a file index.php and the idea of the whole code of the above files is now in the file index.phpin the same scope.

Or is it not working?
March 20th 20 at 11:37
1 answer
March 20th 20 at 11:39
Or is it not working?

It works, but it is better, therefore code is not new.
Functions directly call only index.php in all the included files just to declare a new function or class, and call the already declared functions only in their body.
And the error you got most likely something else, as in the post is not written.

PS and connect files best through an absolute path.

require_once __DIR__ . '/../kernel/helpers.php';

Find more questions by tags PHP