mbrown Posted September 19, 2008 Share Posted September 19, 2008 I am getting confused. i ahve the following code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>State Search</title> <link href="../css/stylesheet.css" rel="stylesheet" type="text/css" /> </head> <body> <?php //includes the top header print $pagetitle; echo "<br /><br /><br />"; include ('header.php'); ... I want to print out the page title on the page within the <?php and the ?> tags. how do i do that I know print $pagetitle does not work. I thought I read online that, that works but I guess not. Mbrown Quote Link to comment https://forums.phpfreaks.com/topic/124950-solved-print-out-page-title/ Share on other sites More sharing options...
.josh Posted September 19, 2008 Share Posted September 19, 2008 $pagetitle is not being set anywhere, so nothing is being printed out. Are you wanting to print out "State Search" inside your php tags? Quote Link to comment https://forums.phpfreaks.com/topic/124950-solved-print-out-page-title/#findComment-645622 Share on other sites More sharing options...
mbrown Posted September 19, 2008 Author Share Posted September 19, 2008 yes sir/mam Quote Link to comment https://forums.phpfreaks.com/topic/124950-solved-print-out-page-title/#findComment-645624 Share on other sites More sharing options...
.josh Posted September 19, 2008 Share Posted September 19, 2008 <?php echo "State Search"; ?> or <?php echo "<title>State Search</title>"; ?> Though if you're making a hardcoded echo like that, no point in really putting it inside the tags. Unless you were wanting that title to be dynamic, in which case you're going to have to come up with code to set $pagetitle to something. Quote Link to comment https://forums.phpfreaks.com/topic/124950-solved-print-out-page-title/#findComment-645626 Share on other sites More sharing options...
mbrown Posted September 19, 2008 Author Share Posted September 19, 2008 <?php echo "State Search"; ?> or <?php echo "<title>State Search</title>"; ?> Though if you're making a hardcoded echo like that, no point in really putting it inside the tags. Unless you were wanting that title to be dynamic, in which case you're going to have to come up with code to set $pagetitle to something. Isnt there a way i can set $PageTitle to what ever is in the <title></title>? Quote Link to comment https://forums.phpfreaks.com/topic/124950-solved-print-out-page-title/#findComment-645632 Share on other sites More sharing options...
Minase Posted September 19, 2008 Share Posted September 19, 2008 huh ??? you can do something like this $title = "My first title"; it need to be above the echo part <title><?php echo $title; ?></title> but if you are having <title>a title</title> and want to get its content into a variable i dont know any way,or if its even possible.... Quote Link to comment https://forums.phpfreaks.com/topic/124950-solved-print-out-page-title/#findComment-645638 Share on other sites More sharing options...
.josh Posted September 19, 2008 Share Posted September 19, 2008 Perhaps you should explain what you're trying to accomplish because that doesn't really make sense. Are you wanting to be able to have the title displayed, and then have a variable ($pagetitle) so you can somehow use it later on? <?php $pagetitle = "State Search"; echo "<title>$pagetitle</title>"; ?> <!-- lots of stuff here --> <?php // do something with $pagetitle here ?> I mean, I suppose you could like, use file_get_contents to have the file read itself and use some regex to grab what's between <title>..</title> or something but I mean, I hope you see how that sounds kind of ridiculous. So uh...perhaps you should paint a picture of what you're overall goal here is... Quote Link to comment https://forums.phpfreaks.com/topic/124950-solved-print-out-page-title/#findComment-645642 Share on other sites More sharing options...
mbrown Posted September 19, 2008 Author Share Posted September 19, 2008 all right thank you! Quote Link to comment https://forums.phpfreaks.com/topic/124950-solved-print-out-page-title/#findComment-645754 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.