PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
jayson.ph
Forum Contributor
Posts: 165 Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:
Post
by jayson.ph » Fri Jun 01, 2012 12:22 am
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..
social_experiment
DevNet Master
Posts: 2793 Joined: Sun Feb 15, 2009 11:08 am
Location: .za
Post
by social_experiment » Fri Jun 01, 2012 12:50 am
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>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
pbs
Forum Contributor
Posts: 230 Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:
Post
by pbs » Fri Jun 01, 2012 12:57 am
Use
<?php include("title.php");?>
jayson.ph
Forum Contributor
Posts: 165 Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:
Post
by jayson.ph » Fri Jun 01, 2012 1:47 am
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?
pbs
Forum Contributor
Posts: 230 Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:
Post
by pbs » Fri Jun 01, 2012 2:11 am
Use "if" or "switch...case" for specific title
social_experiment
DevNet Master
Posts: 2793 Joined: Sun Feb 15, 2009 11:08 am
Location: .za
Post
by social_experiment » Fri Jun 01, 2012 2:39 am
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' ?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
jayson.ph
Forum Contributor
Posts: 165 Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:
Post
by jayson.ph » Fri Jun 01, 2012 2:42 am
what phpscript should i use into home.php?
social_experiment
DevNet Master
Posts: 2793 Joined: Sun Feb 15, 2009 11:08 am
Location: .za
Post
by social_experiment » Fri Jun 01, 2012 2:44 am
You can do the script on the title.php page and return the value
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
jayson.ph
Forum Contributor
Posts: 165 Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:
Post
by jayson.ph » Fri Jun 01, 2012 5:31 am
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.
social_experiment
DevNet Master
Posts: 2793 Joined: Sun Feb 15, 2009 11:08 am
Location: .za
Post
by social_experiment » Fri Jun 01, 2012 5:45 am
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
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Fri Jun 01, 2012 5:50 am
Well, what determines which title gets called? The title page you presented earlier with a bunch of echoes is never going to work.
jayson.ph
Forum Contributor
Posts: 165 Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:
Post
by jayson.ph » Sun Jun 03, 2012 11:18 pm
Thanks a lot guys for the cooperation and to you ==>social_experiment<== thank and now i have good idea because of you guys.. thanks