How do you add a favicon to PHP when you use require?

January 14, 2011 – 3:49 pm

I used the usual <href… type="favicon.png" blah blah> but that didn’t work, so how do you add a favicon using require in PHP?

Related posts:

  1. How do I place a favicon using the require once function in php?
  2. How do you use a favicon.ico image with a perl script site?
  3. How do you use a favicon.ico image with a perl script site?
  4. Can a java interface require a class to have a zero-argument constructor?
  5. How do you do a combobox in python + glade?
  6. Will XAMMP mess up apache and mysql on my computer?
  7. What software do I require to commence with Python programming language?
  8. How can I require a flash drive configuration file to start up Linux?
  9. How can I require a flash drive configuration file to start up Linux?
  10. How do I get the Sibelius Scorch plugin in Linux?
  1. 6 Responses to “How do you add a favicon to PHP when you use require?”

  2. <link rel="icon" type="image/png" href="favicon.png"> is how I add one. to normal html. If you are looking to do it with php require try something like this create a file called html.php or something like that.
    <?php
    function html_start($page,$meta_description,$style)
    {
    global $site_name;
    $meta_keywords="Keywords here";
    $meta_author="CR";
    $meta_copyright="CR";
    $link_stylesheet="$style";
    $link_favicon="image/fav.jpg";
    echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">
    <html>
    <head>
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" >";
    if($meta_description !=NULL)
    {
    echo"
    <meta name=\"description\" content=\"$meta_description\">
    <meta name=\"keywords\" content=\" $meta_kewords \" >";
    }
    echo"
    <meta name=\"author \" content=\"$meta_author \">
    <meta name=\"copyright\" content=\"$meta_copyright \">
    <link rel=\"icon\" type=\"image/png\" href=\"$link_favicon\">

    <link rel=\"stylesheet\" type=\"text/css\" href=\"$link_stylesheet\" >
    <title>$page – $site_name </title>

    </head>
    <body>";
    }
    ?>

    than creat a new page name it what ever you like
    <?php
    require"html.php";
    html_start("Page name",null,style.css)
    ?>

    something like that

    By Toxin on Jan 14, 2011

  3. Require() just includes an external file at that point. If you’re writing your code properly, the favicon link will work in either the main file or the included one.

    <link rel="shortcut icon" href="favicon.png">

    That assumes that favicon.png is in the same directory as the php file (not the included file, which can be anywhere).

    By Colanth on Jan 14, 2011

  4. place this in your header

    <link rel="icon" type="image/jpg" href="yourimagehere.jpg/"/>

    By Matt S on Jan 14, 2011

  5. Actually I would put both

    <link rel="shortcut icon" href="favicon.ico">
    <link rel="icon" type="image/jpg" href="favicon.ico"/>

    Also make sure that you favicon.ico file is located in the root directory.

    http://www.yoururl.com/favicon.ico

    By chillininvt on Jan 14, 2011

  6. You just need to put the following line just below </head> tag in the html code of your webpage –

    <link href=’put favicon url here’ rel=’SHORTCUT ICON’/>

    By Harsh on Jan 14, 2011

  7. it is all in the headers. No where else

    By DzSoundNirvana on Jan 14, 2011

Sorry, comments for this entry are closed at this time.