PHP: [MUST] know methods

Discussion in 'PHP' started by ProgrammersTalk, Jun 14, 2007.

  1. #1
    This language have bunch of methods, do you guys any favorites? share it for me, and what is it for? thanx :)
     
    ProgrammersTalk, Jun 14, 2007 IP
  2. ProgrammersTalk

    ProgrammersTalk Peon

    Messages:
    684
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I guess you guys are not calling it a method, but a function...?
     
    ProgrammersTalk, Jun 14, 2007 IP
  3. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #3
    methods are functions contained inside classes / objects and functions are procedural functions.

    I'm not sure I have a favourite function or class, there are millions, too many :S
     
    krakjoe, Jun 14, 2007 IP
  4. ProgrammersTalk

    ProgrammersTalk Peon

    Messages:
    684
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm sure that there's no way you can memorize all millions of them right? so probably there are some of them that you use most? :-/
     
    ProgrammersTalk, Jun 14, 2007 IP
  5. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #5
    well I wouldn't like to write a big list, but if I'm writing an application I can normally think of two or three ways of doing whatever I'm trying to do.

    I suppose I can think of a list of preferences for programming,

    I'll use substr over preg_match|replace
    mysql_connect over mysql_pconnect
    preg_match over ereg
    split over explode
    arrays over strings
    classes over procedural
    fopen|read|write|close over file_get|put_contents ( not because of speed but control over the process )
    curl over sockets
    fsockopen over sockets
    windows program over php script - oh yes !!
    mysql_fetch_assoc over mysql_result

    you find when you have been doing it for a while most common functions are at the front of your brain
     
    krakjoe, Jun 14, 2007 IP
  6. mrmonster

    mrmonster Active Member

    Messages:
    374
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #6
    isset() // if you're unsure of something :)
    instanceof // not a function, but it makes the code look cooler
     
    mrmonster, Jun 14, 2007 IP
  7. InFloW

    InFloW Peon

    Messages:
    1,488
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Well not a native PHP function but people seem to always think is_int checks for integer on post values and thing of that nature. So here is a simple isInt function that can do integer checks on php strings (post,get,cookie ect.)

    
    function isInt($value)
    {
           return (is_numeric($value) ? intval($value) == $value : false);	
    }
    
    PHP:
     
    InFloW, Jun 14, 2007 IP
  8. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #8
    Don't really have a favorite...

    empty() is useful sometimes.
     
    dp-user-1, Jun 14, 2007 IP