Meta Tags in Php.... how do you do it?

6 replies
i dont know anything about php, so that makes this even more difficult.

how do you do meta tags for keywords, title and description in php?
#meta #php #tags
  • Profile picture of the author ussher
    (more info gets better answers.)
    php doesn't have meta tags. php is a server side language. It can _output_ html and you can put your meta tags in there the same way you would in normal html.
    Signature

    "Jamroom is a Profile Centric CMS system suitable as a development framework for building entire communities. Highly modular in concept. Suitable for enterprise level development teams or solo freelancers."

    - jamroom.net
    Download Jamroom free: Download
    {{ DiscussionBoard.errors[5529993].message }}
  • Profile picture of the author tiptopwarriors
    You can write anything you want in php by writing it within <?php and ?> tags.
    for example you can write any html tag like
    <? echo "<b>This is bold formatted text</b>"; ?>
    or you may use your meta tags as
    <? echo "<META NAME="Description" CONTENT="description of your website.">"; ?>
    {{ DiscussionBoard.errors[5532892].message }}
    • Profile picture of the author Don Art
      Originally Posted by tiptopwarriors View Post

      You can write anything you want in php by writing it within <?php and ?> tags.
      for example you can write any html tag like
      <? echo "<b>This is bold formatted text</b>"; ?>
      or you may use your meta tags as
      <? echo "<META NAME="Description" CONTENT="description of your website.">"; ?>
      and you also need to, what they call, "escape" the inner double quotes like:
      <? echo "<META NAME=\"Description\" CONTENT=\"description of your website.\">"; ?>

      or use surround the whole thing in single quotes like: <? echo '<META NAME="Description" CONTENT="description of your website.">'; ?>
      {{ DiscussionBoard.errors[5533238].message }}
  • Profile picture of the author abramabrar
    Can be done easily if you simply echo meta tags through php.
    Signature
    {{ DiscussionBoard.errors[5533019].message }}
  • Profile picture of the author frenchsquared
    if you are trying to dynamically create them you would make a function the gets passed the page url, then returns the matching meta data.
    {{ DiscussionBoard.errors[5533590].message }}
  • Profile picture of the author ram07
    <title><?php echo $title ?></title>
    <meta name="description" content="<?php echo $description; ?>" />
    <meta name="keywords" content="<?php echo $keywords ?>" />

    Its very simple, First insert relavent title, description and keywords for each page, set a unique key. Then pass the unique key in the query string.

    Fetch the query string value and select the title, description and key words related to the fetched query string value.

    This will do the dynamic meta tags for any php pages.

    Thank you.
    {{ DiscussionBoard.errors[5536016].message }}

Trending Topics