Jump to content
xisto Community
Sign in to follow this  
snlildude87

Writing Your Own Functions In Php how do i write php functions that takes arguments in php?

Recommended Posts

I'll set up the background for the question: I have a separate file that I include on all the webpages on my site which I call with PHP using the include() function, so everything will be much easier to maintain and update. Well, I have three include files for each page: header.php (includes stuff like meta tags, googlebot/spider info), footer.php (the footer/copyright thing), leftnav.php (includes the navigation bar). I also like the titles of my pages to be as descriptive as possible so I try to include the path of a page (how the user got to that page: "Excite Yourself : Games : Reaction") between my <title> tags.

 

Problem: The thing is that I've recently decided to change my site title to something less generic and more creative. I was thinking about moving the title tag in all my pages to the header file first. Is there a way so I can change all the "Excite Yourself"'s without having to update every single page on my site? Like, include the <title> tags in my header.php file?

 

What I was thinking: I was thinking about putting this code in my site:

<html><?php  include("header(title of page).php");?>
However, I don't think the code above is legal in PHP syntax. Then, in header.php, I can have a statement that takes in title of page and append that to "New Title Name : Games : Reaction"

 

As you can tell, I'm not really good with PHP, but I did my best to try to explain to you my situation.

 

Any help/suggestion is appreciated :o

Share this post


Link to post
Share on other sites

How about declare a variable $title before including the header file

$title="This is the title of my new page";include("location-of-header-file.inc.php");

Inside the header file, You can use this variable $title.

<!-- Contents of Header file -->
<html>
<head>
<title><?=$title?></title>
</head>



Try this out, I haven't tested it. But it should work.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.