0

main.php requires 2 files:

require './functions/fileA.php';
require './functions/fileB.php';

fileA.pgp as a function

function doecho($url){echo $url}

In fileB.php, I have a function that calls the doecho function

function withinBfunction($url){doecho($url);}

But I get this error,

Uncaught Error: Call to undefined function curl().

However, if, in fileB.php I call the doecho function outside any function, it works. It seems that the functions in fileB.php cannot access the functions on fileA.php

I took a look at this post (PHP Fatal error: Call to undefined function when function is defined) but the difference is that I am not using classes. Any ideas how I could solve this?

Oh, and, yes, I have turned on the php error log with (error_reporting(E_ALL & ~E_NOTICE & E_STRICT & ~E_DEPRECATED) and all I get is that "call to undefined function".

10
  • 9
    include does not die if the file can't be loaded. use require to make sure the file is loaded correctly. Commented Mar 29, 2018 at 11:41
  • Are you sure that fileA.php is included? Maybe the interpreter cannot find it and the warning it triggers is suppressed by your configuration. Use require instead. Commented Mar 29, 2018 at 11:43
  • If PHP says it's not there, it's not there, no matter what you think. Commented Mar 29, 2018 at 11:52
  • May be you are missing one period in include './functions/fileB.php';. Try include '../functions/fileB.php'; Commented Mar 29, 2018 at 11:55
  • 1
    display errors would have helped you, try debugging before you ask for help. stackoverflow.com/q/5438060/3664960 Commented Mar 29, 2018 at 12:34

1 Answer 1

0

I think you should use two dots for one directory up like: Include '../directory name';

Sign up to request clarification or add additional context in comments.

1 Comment

Hi. Don't think that is the problem. I a using now "require", instead of "include". Both included files are in he same folder. If I put two dots, require fails.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.