Welcome Guest ( Log In | Register)



 
Closed TopicStart new topic
> Writing Your Own Functions In Php, how do i write php functions that takes arguments in php?
snlildude87
post Apr 18 2005, 12:53 AM
Post #1


Moderator
***************

Group: Members
Posts: 2,325
Joined: 8-March 05
From: Mawson, Antarctica
Member No.: 4,254



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:
CODE
<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 smile.gif
Go to the top of the page
 
+Quote Post
OpaQue
post Apr 18 2005, 01:15 AM
Post #2


Administrator
Group Icon

Group: Admin
Posts: 1,448
Joined: 11-June 04
From: Somewhere in Time & Space.
Member No.: 1



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

CODE

$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.

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


Try this out, I haven't tested it. But it should work.
Go to the top of the page
 
+Quote Post
snlildude87
post Apr 18 2005, 01:36 AM
Post #3


Moderator
***************

Group: Members
Posts: 2,325
Joined: 8-March 05
From: Mawson, Antarctica
Member No.: 4,254



Such a simple solution to what seemed to be a complex question. Thanks, OpaQue! I'm voting for you in my own poll laugh.gif

Problem solved -> thread closed smile.gif
Go to the top of the page
 
+Quote Post

Closed TopicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Using The Image Editing Functions Of Php(4)
  2. Globals Inside Functions(4)
  3. Some Php Functions Explaination Required(2)
  4. Wappy's Php Snippets(13)
  5. Gd Functions(2)
  6. Writing To Files And Such(3)
  7. [php](simple) Using Functions To Combine Values In A Form(2)
  8. Encrypt Functions(0)
  9. Security Issue Writing Files(1)
  10. Arrays Outside A Function(3)
  11. Php Functions To Send Mail(4)
  12. Php Email Validation(1)
  13. Functions(7)


 



- Lo-Fi Version Time is now: 24th July 2008 - 02:18 PM