1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Php function

Discussion in 'PHP' started by banibratamitra, Jan 8, 2010.

  1. #1
    I am new in PhP so want to know that can I write a function in different file and how to include them
    Thank's for help me:confused::confused:
     
    banibratamitra, Jan 8, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    Create a new php file and name it what you want too, (but for this example i'll use file.php):

    Then add the function into file.php like:

    <?php
    
    /*
    
    You can read up on creating functions @:
    http://php.about.com/od/learnphp/ss/php_functions_4.htm
    
    */
    
    function functionname() {
    
    //what the function does...
    
    return;
    
    }
    ?>
    PHP:

    Then wherever you want to include the file add:

    <?php
    
    include("file.php");
    
    ?>
    PHP:
     
    Last edited: Jan 8, 2010
    danx10, Jan 8, 2010 IP
  3. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #3
    and in php you can add the function anywhere as its processed after the whole code is run
     
    Bohra, Jan 8, 2010 IP