tags:

views:

88

answers:

2

Hello, I was googling how to make animated favicon in my webpage, I found many tutorial that show I have to add some lines like

<link rel="icon" href="animated_favicon.gif" type="image/gif" >

but problem is I have purely php based web page, not html here. Do I have to make html page with these calls and invoke it from index.php somehow? Or are here other php specific commands?

Thanks.

+1  A: 

After editing to get your HTML snippet out in the open, I think I can start to answer.

First off, PHP and HTML are two entirely different creatures. PHP runs on your server and produces output. HTML is a type of output your PHP can produce, and when running on a web sever, it is the default content type. Most websites (I'd say 99%, if not even 100% given rounding) that use PHP also use HTML.

If you're instead crafting, say, a website that only uses plain text (talk about hard to navigate), you're out of luck. Browsers will automatically look for your favicon at /favicon.ico, but if you want to also offer an animated GIF, you need to state that using the HTML tag you've given. Nothing else (HTTP headers, etc.) can mimic that effect.

But seriously, if you're not using HTML for your website, what are you using?

Matchu
I really want to know what he's using too.
ehdv
A: 

First off: you can't have a web page without HTML. Other files types can be served up (PDF, Flash, images, text files, etc.) but for a web page you need HTML.

PHP was designed to be interspersed with HTML or any other text. Anything not encapsulated in <?php ?> blocks is sent to stdout. At a bare minimum to get your PHP page to output HTML do the following:

<?php
 /*
  * My PHP code goes here
  */
?>
<html>
<head>
<link rel="icon" href="animated_favicon.gif" type="image/gif" />
</head>
<body>
My web page
</body>
</html>

From your question it sounds like you might be using custom PHP libraries to generate the HTML for the web page. In this case the above example won't work, you'll have to consult the documentation for the libraries.

pygorex1
Just nit-picking, but true: Every HTML document **must** have a `TITLE` element in the `HEAD` section. http://www.w3.org/TR/REC-html40/struct/global.html#h-7.4.2
Marcel Korpel