简体   繁体   English

将HTML嵌入PHP的正确方法

[英]Right way for embedding HTML into PHP

I have a define.php page that has many variables in it. 我有一个define.php页面,里面有很多变量。 I use to include in any other PHP file I make. 我用来包含在我制作的任何其他PHP文件中。

There is a variable named $encodingdeclaration which has <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> . 有一个名为$encodingdeclaration的变量,它具有<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? 该脚本现在变得无法响应:因为在text/html之后使用了额外的分号,该怎么办?

meta http-equiv should be moved to .htaccess file Adding it inline the way you do will cause html validating to fail. 应该将meta http-equiv移动到.htaccess文件以内联方式添加内联将导致html验证失败。

If its a html5 page, simply add the below before your [title] tag 如果是html5页面,只需 [title]标签之前添加以下内容即可

<meta charset="UTF-8" />

Also use double quotes for strings such as these. 对这些字符串也使用双引号。

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

使用此代码

$encodingdeclaration = '<meta http-equiv="content-type" content="text/html;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. 只要它正确地包裹在一个字符串中,分号就不会有任何影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM