簡體   English   中英

如何將html + script放在image.php文件中

[英]how put html+script inside the image.php file

我無法合並這些代碼

把這個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>

內部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)
?>

預期輸出

在此處輸入圖片說明

使用include()require() 它可以在php中加載html文件

例如

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")
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM