please help me

Discussion in 'PHP' started by husain, Jun 25, 2010.

  1. #1
    hello freinds

    i am new in php

    i am just learning

    can any body tell me what is the best use of function in PHP
     
    husain, Jun 25, 2010 IP
  2. adamsinfo

    adamsinfo Greenhorn

    Messages:
    60
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #2
    Please adjust your font/size before posting.
    The best use of a function in PHP or in any language for that matter is to create a block of code or literally 'function' that will likely be executed more than once. A [useless] example is:

    function addone($v)
    {
    $v++;
    return $v;
    }

    This function adds 1 to whatever is passed to it. So, throughout your code you could use:
    $a = 1;
    $a = addone($a);

    $a now becomes 2
     
    adamsinfo, Jun 25, 2010 IP
  3. techbongo

    techbongo Active Member

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    80
    #3
    The best use of PHP function is to make it simpler than Java, in my words. PHP 5.0 is OOP language but it gives you the scope to write non-Object Oriented codes. PHP functions make the language easy and this is why experts in Java is more than that of Experts in PHP, but novice is PHP is quite a lot compared to Java.
     
    techbongo, Jun 25, 2010 IP
  4. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #4
    in my case i use function to lessen redundant code and make it more beautiful
     
    gapz101, Jun 25, 2010 IP