Wow I'm gonna try to explain how I solve it but I'm confused about what I did XD
First I created a new document. So we have Main.php "plane" php, function.php with the function, required.php the required third party with plenty of classes, functions..., and now newone.php the new document with a new function.
Document Main.php requires function.php and newone.php
newone.php have a function where I put in it all what Main.php and function.php needed to do with the required.php, and I return what they need, and as it is a function there are no problems to use it in any document.
At this point I had the same problems than before but with more documents involved
, but finally I come out with these in newone.php:
PHP Code:
function newfunction($var) {
global $variable_from_required_document;
require_once('required.php');
// Do thing and return things
}
As you can see I call that global variables and then require the document that makes them, but that’s the only way it works.
I suppose that the second time the function is called it catches the variables from the first call, and it does not require required.php
For last, if I put first the require_once and then the global, the first time is called that global overwrites the variables so it does not work, thats why is reversed.
And that's it, I think I see it clear now.
Bookmarks