Welcome Guest ( Log In | Register )

2 Pages V   1 2 >  
Reply to this topicStart new topic
> Creating A Basic Php Copyright Function, Beginner
Jambo
post Dec 21 2004, 06:56 AM
Post #1


Addicted Dot
Group Icon
Group: *Premier*
Posts: 1,093
Joined: 19-May 04
From: The UK
Member No.: 4





By the time you finish this tutorial you'll know how to create a basic php function.

Using the php function method is easy, if you want to know how to do it, feel free to read on smile.gif

Open up Notepad.

What do you want inside a function? In my example, it will echo Copyrights!

This is just one example of adding a function to your pages footer, instead of creating multiple codes at the bottom of every page, you can just have one code that will echo the same thing everytime.

Its a bit like a include or require function.

Start with:

CODE
<?
     function page_footer()   {
           echo "<hr><center><p>Copyrights!</p></center>";
}
?>


That is your source of what you're going to include, so its going to display a horizontal line then center text afterwards then show 'Copyrights!'


Now, in your page anywhere you like (Prefered at the bottom for copyrights function) you can pull and echo this function, by this, you use the code:

CODE
<php
       page_footer();
?>


I hope this is some help, it took me a few minutes to work it out by trying all sorts of different methods smile.gif

My page code is:

CODE
<?
    function page_footer() {
 echo "<hr><center><p>Copyrights!</p></center>";
}
    $title = "Jamie is kewl!";
?>

<html>
<head>
<title><? echo $title; ?></title>
</head>
<body>
<br>
<br>
<br>
<br>
<?php
    page_footer()
?>
</body>
</html>


You can preview this at: http://www.darkadventure.com/function_generate.php


I hope its made those who want to learn php know about the functions.

Any questions please ask.


IPB
 
+Quote Post  Go to the top of the page
cmonney
post Dec 21 2004, 07:12 AM
Post #2


~ Soul Rebel ~
Group Icon
Group: Main Team*
Posts: 3,624
Joined: 18-May 04
From: a mind-altering psychedelic trip
Member No.: 3





Thanks Jamie... thumbsup.gif


IPB
cmonney
"Oh!, Great Creator of Being, grant us one more hour to perform our art and perfect our lives... We live, we die, and death not ends it..."

Topsites Is Back Open - Add Your Site
 
+Quote Post  Go to the top of the page
Jambo
post Dec 21 2004, 07:27 AM
Post #3


Addicted Dot
Group Icon
Group: *Premier*
Posts: 1,093
Joined: 19-May 04
From: The UK
Member No.: 4





QUOTE(cmonney @ Dec 21 2004, 07:12 AM)
Thanks Jamie...  thumbsup.gif
*



No problems fest24.gif

Have a lovely Christmas!!


IPB
 
+Quote Post  Go to the top of the page
cmonney
post Dec 21 2004, 09:49 AM
Post #4


~ Soul Rebel ~
Group Icon
Group: Main Team*
Posts: 3,624
Joined: 18-May 04
From: a mind-altering psychedelic trip
Member No.: 3





QUOTE(Jambo @ Dec 21 2004, 10:27 AM)
No problems  fest24.gif

Have a lovely Christmas!!
*



THank yOu... U 2~!!!

fest24.gif


IPB
cmonney
"Oh!, Great Creator of Being, grant us one more hour to perform our art and perfect our lives... We live, we die, and death not ends it..."

Topsites Is Back Open - Add Your Site
 
+Quote Post  Go to the top of the page
Eric
post Dec 21 2004, 10:16 AM
Post #5


Good Ol' Dot
Group Icon
Group: Honored
Posts: 364
Joined: 20-May 04
From: USA
Member No.: 16





thanks Jambo.
 
+Quote Post  Go to the top of the page
Rob Wells
post Dec 22 2004, 08:32 AM
Post #6


Moderator Assassin ™
Group Icon
Group: Moderator
Posts: 1,178
Joined: 27-July 04
From: The UK
Member No.: 463





Thanks Jamie,
I need to learn php it seems to have a great advantage over plain html,

-rob smile.gif


IPB
 
+Quote Post  Go to the top of the page
*D*
post Dec 22 2004, 09:25 AM
Post #7


Merry KissMoose
Group Icon
Group: Main Team
Posts: 15,988
Joined: 18-May 04
From: North Pole
Member No.: 2





Thanks, try & get into the practice of adding doc type as well because all of the above is very useless to someone trying to validate this without it.
 
+Quote Post  Go to the top of the page
socorro
post Oct 12 2005, 01:02 AM
Post #8


New Member
Group Icon
Group: Member
Posts: 20
Joined: 11-October 05
Member No.: 7,490





Thanks Jamie


IPB
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into your
(")_(") signature to help him gain world domination.
 
+Quote Post  Go to the top of the page
jammo
post Nov 11 2005, 05:29 PM
Post #9


Regular Dot
Group Icon
Group: Member
Posts: 72
Joined: 10-November 05
From: Fort Worth, TX USA
Member No.: 8,118





mine is pretty similar:

CODE
// functions.php
function page_footer() {
$copyrightyear = date("Y");
print "© 2003-" . $copyrightyear ." jammo.net™";
}


CODE
// page.php
    <div id="footer">
        <?php page_footer(); ?>
    </div>
 
+Quote Post  Go to the top of the page
Maya_Karen
post Apr 5 2007, 11:59 PM
Post #10


New Member
Group Icon
Group: Member
Posts: 11
Joined: 5-April 07
Member No.: 15,717





thanx jami
 
+Quote Post  Go to the top of the page

2 Pages V   1 2 >
Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 1st December 2008 - 10:57 PM
Mortgage Calculator | Personal Loan | Loan | Mortgage Calculator | Music Festival