How can I echo the page title into this?

Discussion in 'PHP' started by Airwalk Enterprise, Inc, May 1, 2010.

  1. #1
    <?php $facebook="I want to echo the page title here"; include("../../../comment.php");?>
     
  2. lorkan

    lorkan Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi!

    PHP is server side scripting and would therefore not enable you to retrieve a page's title because it lies on the client side. However I would suggest that you changed in your html part of the side to do something like this...
    First:
    <?php $title="Your Page Title"; ?>
    PHP:
    Then:
    
    <html>
    <head>
    ...
    meta tags
    ...
    <title><?php echo $title; ?></title>
    </head>
    <body>
    ....
    
    HTML:
    Finally, in your script you could easily put $facebook=$title; and get the same result.
     
    lorkan, May 1, 2010 IP
  3. Airwalk Enterprise, Inc

    Airwalk Enterprise, Inc Peon

    Messages:
    126
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'd then have to go and change all the title tags, I want it done this way so that I can just put my php include into each page and its done, but with a variated ID somehow :(
     
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    Confused?, explain please.
     
    danx10, May 2, 2010 IP
  5. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #5
    well isnt it a php script your are editing so why would you have to edit all pages
     
    Bohra, May 2, 2010 IP