+1 vote
by
There is a file 1.php in which
This is roughly the design:
include_once("include/functions.php");
include_once("include/db_functions.php");

class Script
{
private $function;
private $DB;

public function __construct()
{
$this->function = new Functions();
$this->DB = new DB();
}

public function Start()
{
include_once("api.php");
$api = new API();
}
}
if (isset($_POST)) {
$object = new Script();
$object->Start();
}
Now we're looking at api.php :
class API
{
public function Test($serviceId)
{
//....
include_once("include/functions.php");
$function = new Functions();
}
}
Thus, I get an error, saying $functions is redefined... How do I solve/verify this beforehand?
by
Can't the API class be inherited from the Script class and passed between them via $this->function ?

1 Answer

0 votes
by
 
Best answer
the question is a hell of a vinaigrette.
What do you mean, "the $functions are redefined"?
$functions is a variable; there can be as many variables as you want.
Functions class? You use include_once, which means that the file with the class definition should only be loaded once.

Okay, you don't know a thing about programming, you're just taking your first steps in oo. Can you at least write the error in a human way? And give me code that corresponds to this error and does not contradict it?
...