SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist spoondevil's Avatar
    Join Date
    Jun 2001
    Location
    Harlow, Essex, UK
    Posts
    426
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    get_meta_tags Doesn't Work

    I've tried using the get_meta_tags to work, but to no avail. Anyone know why this might be?
    PHP Code:
    <?php
         $tags 
    get_meta_tags 'http://www.yahoo.com/' );
          echo 
    $tags['title'];
          echo 
    $tags['description'];
     
    ?>
    Just comes back empty.

    I'm using version 4.4.0 of PHP.

    Ian

  2. #2
    Wadge! F4nat1c's Avatar
    Join Date
    Oct 2005
    Location
    South Wales, UK
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's because yahoo doesn't have those meta tags in it's source. Try this example instead:

    PHP Code:
    <?
       $tags 
    get_meta_tags("http://dmoz.com/");

               echo 
    $tags['description'];
               echo 
    $tags['keywords'];
    ?>
    The sourcefile of dmoz.com contains:

    Code:
    <meta name="description" content="Help build the most comprehensive human-reviewed directory of the web">
    <meta name="keywords" content="search, directory, community, web directory, web search, search engine">
    The meta tags have to be present for PHP to read and output them.

    Let me know how it goes.
    OMFG SitePoint ROXORZ TEH BIG ONE111!
    Wish you were invisible?

  3. #3
    Wadge! F4nat1c's Avatar
    Join Date
    Oct 2005
    Location
    South Wales, UK
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did it work alright?
    OMFG SitePoint ROXORZ TEH BIG ONE111!
    Wish you were invisible?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •