开发者

How to echo something inside the head section of a page using PHP

I wa开发者_如何学Pythonnt to echo a stylesheet inside the head section of a web page. Right now when I do this:

if($browser == "Opera")
{
    echo "<link type='text/css' rel='stylesheet' src='/opera.css' media='screen' />";
}

it does echo the style sheet in the source code and not the page itself which is good but it doesn't echo it inside the <head></head> section. How can this be done?


Placing the structure after the code that prints <head> and before the code that prints </head> will put that tag within the head section of the page.


Unless you're working with a framework (like WordPress or Moodle) that "helps" you generate pages, the only output PHP creates is up to you. So, if you output that <link /> tag between your <head> and </head> tags (which you must be outputting elsewhere in your script), that's precisely where it will appear.

If you are using WordPress or Moodle or Drupal or some other content management system (or other PHP framework), it's up to that framework how new content gets added to the head.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜