将HTML嵌入PHP的正确方法

I have a define.php page that has many variables in it. I use to include in any other PHP file I make.

There is a variable named $encodingdeclaration which has <meta http-equiv="Content-Type" content="text/html; charset=utf-8">.

The script now is becoming unresponsive: that because of an extra semicolon used after text/html, What to do?

meta http-equiv should be moved to .htaccess file Adding it inline the way you do will cause html validating to fail.

If its a html5 page, simply add the below before your [title] tag

<meta charset="UTF-8" />

Also use double quotes for strings such as these.

$encodingdeclaration = "<meta charset=\"UTF-8\" />";

I can't really tell without you providing the actual code, but make sure that you're using single quotes around your string, since double quotes might conflict. A semi-colon will not have any impact as long as it's properly enclosed in a string.

Use this code

$encodingdeclaration = '<meta http-equiv="content-type" content="text/html;charset=UTF-8" />';