使用PHP生成iMacro语法-<;标准普尔>;空间

使用PHP生成iMacro语法-<;标准普尔>;空间,php,string,imacros,Php,String,Imacros,我需要生成imacro语法,以便用户能够从浏览器屏幕进行复制 由于iMacro将用于空格,因此我需要将包含空格的数据库值替换为 这不起作用,因为浏览器将识别为HTML字符 $srtnew = str_replace(" ","<SP>",$string); $srtnew=str\u replace(“,”,$string); 有什么建议吗?您需要做: header("Content-Type:text/plain"); 在输出之前 这告诉浏览器以纯文本格式而不是html格式输

我需要生成imacro语法,以便用户能够从浏览器屏幕进行复制

由于iMacro将
用于空格,因此我需要将包含空格的数据库值替换为

这不起作用,因为浏览器将
识别为HTML字符

$srtnew = str_replace(" ","<SP>",$string);
$srtnew=str\u replace(“,”,$string);
有什么建议吗?

您需要做:

header("Content-Type:text/plain");
在输出之前

这告诉浏览器以纯文本格式而不是html格式输出内容

当然你也可以这样做:

$srtnew = str_replace(" ",htmlentities("<SP>"),$string);
$srtnew=str\u replace(“”,htmlentities(“”),$string);
如果您有许多标记,如果您只想输出代码,以便让用户复制它们,那么您应该设置标题


有关在PHP中设置标题的详细信息:

您可以将HTML实体用于尖括号(
):

或者,您可以使用PHP对括号进行编码:

$srtnew = str_replace(" ",htmlentities("<SP>"),$string);
$srtnew=str\u replace(“”,htmlentities(“”),$string);

$srtnew = str_replace(" ",htmlentities("<SP>"),$string);