[英]how to put text in middle of two words in php
I am editing a HTML file with Php but when i tried to write some text in between the body tag我正在用 Php 编辑 HTML 文件,但是当我尝试在 body 标记之间写入一些文本时
it should look like:它应该看起来像:
<body>Hello</body>
but my code is doing this:但我的代码是这样做的:
<body><hello
php file: php文件:
fwrite($myfile, $html);
$page = strpos($html, "body>");
$pagei = (int)$page + (int)"6";
fseek($myfile, $pagei);
fwrite($myfile, "hello");
I am new in php, i searched internet all day but didn't find anything on how to fix this.我是 php 新手,我在网上搜索了一整天,但没有找到任何关于如何解决这个问题的信息。
str_replace('<body></body>', '<body>Hello</body>', $allText);
or consider adding placeholders:或考虑添加占位符:
<html>
<head></head>
<body>
{content}
</body>
</html>
and then:进而:
str_replace('{content}', 'Hello', $allText);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.