Forgot Password / Register
Site Statistics
Total Members: 510
Total Tutorials: 242
Newsest User: Hp
Todays Unique Hits: 121
0 Users 2 Guests Online

Make your own function

Right first off we do this:


I will call my function "TextDisplay", you can call yours Chimpanzee for all i care :P


PHP Code
1
2
3
4
5
6
<?
function TextDisplay() {
print 
"Text Goes Here";
}
?>


That basically defines what the function actually is and does, and it does not display anything at the moment.

To call that function you would SIMPLY need to put

PHP Code
1
2
TextDisplay();


So the end script would look like this:

PHP Code
1
2
3
4
5
6
7
8
<?
function TextDisplay() {
print 
"Text Goes Here";
}

TextDisplay();
?>
Jackboy
Author:
Views:
1699
Rating:
Posted on Sunday 10th August 2008 at 10:06 PM
ilyas-shezad
ilyas-shezad
try using....
PHP Code
1
2
3
4
<?
echo TextDisplay();
?>
Posted on Thursday 22nd May 2008 at 01:57 AM
ShadowMage
ShadowMage
i tried this on mine and figured out i have a global php include and it failed epically.

But, yeah might be your server though i'm not totally sure.
Posted on Tuesday 20th May 2008 at 03:17 AM
Adam981
Adam981
its the same as what the tut says, i wanted to play around with it but even that doesnt work.. only time it works is if i put it all together.. rather then just the funcation and call it somewhere else on that page.
Posted on Tuesday 20th May 2008 at 03:02 AM
ShadowMage
ShadowMage
did you use the right function name? was it meant to return something or print some text? do you have to fill in for a variable for it to print? xP
Posted on Tuesday 20th May 2008 at 01:52 AM
Adam981
Adam981
lol im not that stupid :P its a php file
Posted on Tuesday 20th May 2008 at 01:29 AM
ShadowMage
ShadowMage
if its an HTML File it won't happen x]
Posted on Monday 19th May 2008 at 11:27 PM
Adam981
Adam981
i make a functions.php page then inclued the page then tryed to call it.
Posted on Monday 19th May 2008 at 10:32 PM
DanielXP
DanielXP
did you put the TextDisplay(); in a php page and put it in the php tags?

PHP Code
1
2
3
4
<?php
include("yourfile.php");
TextDisplay();
?>
Posted on Monday 19th May 2008 at 10:04 PM
Adam981
Adam981
Hmm well i made my page and included it, but when i called on the TextDisplay(); it didn't work. just shows "TextDisplay();"
Posted on Sunday 11th May 2008 at 10:44 AM
Enros
Enros
LOL thats usually why people make the page
functions.php