我无法合并这些代码
将此 html代码
<div id="time"></div>
<script>
function Timer() {
var dt=new Date()
document.getElementById('time').innerHTML=dt.getHours()+":"+dt.getMinutes()+":"+dt.getSeconds();
setTimeout("Timer()",1000);
}
Timer();
</script>
inside image.php
<?php
header("Content-type: image/png");
$str1= " $_SERVER[REMOTE_ADDR]";
$str2= "**place code html**";
$image= imagecreate(200,40);
$background = imagecolorallocate($image,255,255,255);
$color= imagecolorallocate($image,0,0,0);
imagefill($image,0,0,$background);
imagestring($image,10,5,5,$str1,$color);
imagestring($image,10,5,20,$str2,$color);
imagepng($image)
?>
输出预期
答案 0 :(得分:0)
使用include()
或require()
。它可以加载php中的html文件
e.g。
index.html:
<div class="node">hello, world!</div>
include.php
<?php
include("index.php");
?>
导致include.php:
hello, world!
它会正常工作
<?php
header("Content-type: image/png");
$str1= " $_SERVER[REMOTE_ADDR]";
$str2= "**place code html**";
$image= imagecreate(200,40);
$background = imagecolorallocate($image,255,255,255);
$color= imagecolorallocate($image,0,0,0);
imagefill($image,0,0,$background);
imagestring($image,10,5,5,$str1,$color);
imagestring($image,10,5,20,$str2,$color);
imagepng($image)
include("image.html")
?>