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. function TextDisplay() {
  3. print "Text Goes Here";
  4. }
  5. ?>


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. TextDisplay();


So the end script would look like this:

PHP Code
  1. <?
  2. function TextDisplay() {
  3. print "Text Goes Here";
  4. }
  5.  
  6. TextDisplay();
  7. ?>
Jackboy's Avatar
Author:
Views:
2,582
Rating:
Posted on Sunday 10th August 2008 at 10:06 PM
ilyas-shezad
ilyas-shezad's Avatar
try using....
PHP Code
  1. <?
  2. echo TextDisplay();
  3. ?>
Posted on Thursday 22nd May 2008 at 01:57 AM
ShadowMage
ShadowMage's Avatar
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's Avatar
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's Avatar
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's Avatar
lol im not that stupid :P its a php file
Posted on Tuesday 20th May 2008 at 01:29 AM
ShadowMage
ShadowMage's Avatar
if its an HTML File it won't happen x]
Posted on Monday 19th May 2008 at 11:27 PM
Adam981
Adam981's Avatar
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's Avatar
did you put the TextDisplay(); in a php page and put it in the php tags?

PHP Code
  1. <?php
  2. include("yourfile.php");
  3. TextDisplay();
  4. ?>
Posted on Monday 19th May 2008 at 10:04 PM
Adam981
Adam981's Avatar
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's Avatar
LOL thats usually why people make the page
functions.php