Jump to content

PHP page title from strings---how do I do it?


Recommended Posts

How do I use this code for my page title.

<title><?=$page_title?></title>

MY site uses PHP and I want certain things from the page to also show as title of page. For example the City, and Type of listing.
for example if I want these two information to show in the title: Don't have experience in PHP

<? echo $info[listing_style] ?> (string)

and/or

<? echo $info[listing_address] ?> (string)

And once i get the right combination, where Do i put <title> ..........</title> ?

thanks.
<title></title> needs to be placed in the <head></head> section of your page.
[code]
<?php
$myTitle = "This is my website";

?>
<html>
<head>
  <title><?php echo $myTitle;?></title>
</head>
<body>
  This is where the content of the website goes
</body>
</html>
[/code]

As for where you get the information from, it could be set statically like it is in my above example or pulling from a Database such as MySQL which would/could be more dynamic.
This is what I did, got no title. .

<head>
<?php
$myTitle = "This is my website";

?>
<meta http-equiv="Content-Language" content="en-us">
<title><?php echo $listing_style;?></title>
<META NAME="description"


And yes the information I want on the title dynamic/veriable from database
<?php
$lStyle = listing_style";
$lCity = "listing_city";
?>

<title><?php echo $lStyle . " " . $lCity ;?></title>

That's what Sharkbait (I misstated it earlier--gotit is the original poster).

Just remember, you're using PHP to create the HTML code nothing more. 

defiently. if you look carefully at the php code given. $lStyle is set as listing_style which explains why it is outputing listing_style on your title, the same for listing_city.
listen to roopurt18. go learn the basics of php...
You imply that you already have the variables set fir listing style and listing address, how ever you don't say where you get the information from.  If they are already set, you can use:

<head>

<title><?php echo $info[listing_style]." ". $info[listing_address]; ?></title>

</head>

However, you are going to have to make sure the bit of code that you use to declare these variables are positioned before the head tags.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.