我在一个文件中创建了一个 PHP 类,现在我想在我的 HTML 页面中使用它。
我应该将require
orinclude
语句放在 HTML 页面的什么位置?
在 HTML 的开头或结尾加载它是否存在性能差异,或者根本没有差异?
应该是<meta charset="X">
PHP 脚本之前的,所以如果类太长我不会对字符集有任何问题?
例子:
<?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;
?>