Jump to content
mahenda

how to change page title dynamically

Recommended Posts

/*i have some pages and i want to user to see an  appropriate title when user click new page
example: at home page on the tab the title  must be written as 
welcome at hendra|home

and when user clicked on about page, the tab must show another title like this

you are  at hendra|about page

how to do this in php*/



//head
<!doctype html>
  <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
         <meta charset="UTF-8">
         <meta http-equiv="X-UA-Compatible" content="IE=edge">
         <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
      
         <title><?php echo $title; ?></title>
     </head><!--/end of head-->
<body>
  
  
//index page
<?php 
include_once('head.php');
$title = 'welcome at hendra|home';
?> 
 //about page
<?php 
include_once('head.php');
$title = 'you are at hendra|about page';
?>  
  
  

 

 


 

Share this post


Link to post
Share on other sites

Put your PHP code before the HTML code in your scripts.

Then things like $title can be given a value before you output them

Share this post


Link to post
Share on other sites
14 minutes ago, Barand said:

Put your PHP code before the HTML code in your scripts.

Then things like $title can be given a value before you output them

thank you so much now it is working

Share this post


Link to post
Share on other sites

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.