-1

現在、画像のhtmlステートメントがあり、html内に追加したいと思います。

$html=file_get_contents('../template/'.$html);
    $img="<img src='http://localhost/fyp/ga/test.php?=$ga'>";
    file_put_contents($html,$img);

ただし、これによりブラウザからの警告が発生します。また、の後にimgステートメントが追加されるため、phpを使用して内部に追加するにはどうすればよいですか?ありがとうございました。

$img="<img src='http://localhost/fyp/ga/test.php?=$ga'>";

次のような警告が表示されます。

Warning: file_put_contents(<p> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> <!-- Facebook sharing information tags --></p> <p> <meta content="*|MC:SUBJECT|*" property="og:title" /> </p> <p> <title></title> <style type="text/css"> /* Client-specific Styles */ #outlook a{padding:0;} /* Force Outlook to provide a "view in browser" button. */ body{width:100% !important;} .ReadMsgBody{width:100%;} .ExternalClass{width:100%;} /* Force Hotmail to display emails at full width */ body{-webkit-text-size-adjust:none;} /* Prevent Webkit platforms from changing default text sizes. */ /* Reset Styles */ body{margin:0; padding:0;} img{border:0; height:auto; line-height:100%; outline:none; text-decoration:none;} table td{border-collapse:collapse;} #backgroundTable{height:100% !important; margin:0; padding:0; width:100% !important;} in C:\xampp\htdocs\fyp\mail\send.php on line 47
4

1 に答える 1

0

HTML内にプレースホルダーがあると思います。たとえば、{IMAGE}の場合、このプレースホルダーを次のように簡単に置き換えることができます

<?php
  $html = str_replace("{IMAGE}","<img src='http://localhost/fyp/ga/test.php?=".$ga."'>",$html);
?>
于 2012-04-16T20:19:34.347 に答える