Page 1 of 1
php call page title?
Posted: Fri Jun 01, 2012 12:22 am
by jayson.ph
Hi all,
i have a 2 pages that using .php and the one page is for the content = home.php and the other 1 is for the title name page = title.php. and now i have no idea how to a call a title name into home.php
sample--> home.php
Code: Select all
<!DOCTYPE html>
<head>
<title><?php ?></title>
</head>
<body>
</body>
</html>
-->title.php
i want put Philippines name as a title and now how to call it into home.php
Please help..
Re: php call page title?
Posted: Fri Jun 01, 2012 12:50 am
by social_experiment
You can use 'include_once'; just make sure the path to the file is correct
Code: Select all
<title><?php include_once 'title.php'; ?></title>
Re: php call page title?
Posted: Fri Jun 01, 2012 12:57 am
by pbs
Use
<?php include("title.php");?>
Re: php call page title?
Posted: Fri Jun 01, 2012 1:47 am
by jayson.ph
Thank you for the reply..
What if there are a lot of text content inside the title.php
sample:
Code: Select all
<?php echo "Philippines";?>
<?php echo "China";?>
<?php echo "Japan";?>
<?php echo "Autralia";?>
<?php echo "USA";?>
and i want only philippines should be an output into a title.. please help?
Re: php call page title?
Posted: Fri Jun 01, 2012 2:11 am
by pbs
Use "if" or "switch...case" for specific title
Re: php call page title?
Posted: Fri Jun 01, 2012 2:39 am
by social_experiment
If the title is dependant on certain conditions you will need a conditional statement to determine what is displayed; What will determine if you display 'philippines' ?
Re: php call page title?
Posted: Fri Jun 01, 2012 2:42 am
by jayson.ph
what phpscript should i use into home.php?
Re: php call page title?
Posted: Fri Jun 01, 2012 2:44 am
by social_experiment
You can do the script on the title.php page and return the value
Re: php call page title?
Posted: Fri Jun 01, 2012 5:31 am
by jayson.ph
ah okay but ah.. my main question here is ah a phpscript, like you answer earlier, that i use include but as i know include is to call a whole inside in the page.
Re: php call page title?
Posted: Fri Jun 01, 2012 5:45 am
by social_experiment
jayson.ph wrote:my main question here is ah a phpscript, like you answer earlier, that i use include but as i know include is to call a whole inside in the page.
I don't understand the question completely so i've pasted an example to convey my reasoning; i hope this clears things up for you
Code: Select all
// on inco_page.php
My name is <?php include_once 'page.php'; ?>
And inside page.php is this code
Code: Select all
<?php
function total($var) {
$name = $var;
echo $name;
}
total('LavaBlob');
?>
Which will return "My name is LavaBlob " if you run inco_page.php
Re: php call page title?
Posted: Fri Jun 01, 2012 5:50 am
by Celauran
Well, what determines which title gets called? The title page you presented earlier with a bunch of echoes is never going to work.
Re: php call page title?
Posted: Sun Jun 03, 2012 11:18 pm
by jayson.ph
Thanks a lot guys for the cooperation and to you ==>social_experiment<== thank and now i have good idea because of you guys.. thanks