Where should I put a PHP include/require statement in HTML?
character-encoding, class, html, php
Solution
You have to put it anywhere before the code that depends on it is called. Otherwise where you place it won't affect performance.
Many applications typically include files they are dependent on at the top of the file as it makes it easier t keep track of what you're using that way.
Problem
I created a PHP class inside a file, and now I want to use it in my HTML pages. Where should I put the `require` or `include` statement inside the HTML page? Is there a performance difference between load it at the beginning or at the end of the HTML, or is there no difference at all? Should be the `<meta charset="X">` before than the PHP script, so if the class is too long I won't have any problem with the char sets? Example: ``` <?php //Should I load the class here? //include "/var/www/php/db.php"; //$classDB = 'DB'; //$bdd = new $classDB; ?> <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>Nothing</title> </head> <body> <?php $bdd->ShowClientList(); ?> </body> </html> <?php //or should I load the class here? //include "/var/www/php/db.php"; //$classDB = 'DB'; //$bdd = new $classDB; ?> ```