search

Home  >  Q&A  >  body text

Please give me some advice, how to add content in the <head> tag of an HTML file using PHP?

    // 追加内容
    $file = fopen(dirname(dirname(__FILE__)).'/index.htm', 'r');
    $content = fread($file, filesize(dirname(dirname(__FILE__)).'/index.htm'));    
    $hello = '<link type="text/css" rel="stylesheet" href="/css/hover.css" />' . PHP_EOL . $content;
    fclose($file);
    $file = fopen(dirname(dirname(__FILE__)).'/index.htm', 'w');
    echo fwrite($file, $hello);
    fclose($

人生若只是初见人生若只是初见1881 days ago1082

reply all(1)I'll reply

  • 殘留の回憶

    殘留の回憶2019-12-05 18:58:12

    Change the html file suffix to .php and add the original php code directly to the required location on the page

    reply
    0
  • Cancelreply