U
U
Us592020-04-23 23:32:07
PHP
Us59, 2020-04-23 23:32:07

How to distribute functions?

class NewClass {

public function Name () {
        include("function.php");
        $function = new Functions($DSN_DO, $DB_USER_DO, $DB_PASS_DO, $OPTIONS_DO);

         // какой-то код здесь
        include("test.php");
        $test = new Test();
}
}
$object = new NewClass();


How to put things in order? There are basic functions with queries to the database, I decided to put them in a separate file called function.php.

The problem is that if I call include("test.php");, and in the file test.phpin the function that I call, the definition also occurs include("function.php");, then I get an error that function.php is already defined.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-04-23
@Us59

Use include_once()insteadinclude()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question