SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    Serial Site Creator ToddW's Avatar
    Join Date
    Feb 2004
    Posts
    792
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow Most common PHP functions

    What are the most common php functions you use?

    Or, what are the most common php code you use? For example, loops, if statements etc.

    If you use dreamweaver what do you keep in "snippets" because you use them a lot?

    -Todd

  2. #2
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ToddW View Post
    If you use dreamweaver what do you keep in "snippets" because you use them a lot?
    sorry but EW YUCK

    most common ones I use?

    str_replace
    strpos
    strip_tags


    most common loops? it's a toss up between while and foreach ... both for good reasons:

    PHP Code:
    while($row $db_obj->getRows()) {
      
      } 
    and

    PHP Code:
    foreach ($array as $key => $value) {
      
      } 
    And as far as 'snippets' .. don't use them. I build objects that do one job and do it well so I can re-use them over and over

  3. #3
    Serial Site Creator ToddW's Avatar
    Join Date
    Feb 2004
    Posts
    792
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's so EWW Yuck, about dreamweaver?

  4. #4
    _ silver trophy ses5909's Avatar
    Join Date
    Jul 2003
    Location
    NoVa
    Posts
    5,467
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Split and trim would have to be the functions I use the most!
    Sara

  5. #5
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,561
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    echo and var_dump perhaps.

  6. #6
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kailash Badu View Post
    echo and var_dump perhaps.
    echo isn't a function tho :P

    Anyways

    PHP Code:
    header('content-type: text/plain'); 
    Is atop a least 99% of all my php files running around on my development server. So I say i use that the most.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  7. #7
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Kailash, i have another one print_r() too.
    And other than the functions of PHP the word "test" is my regular word that I use more frequently. Lol!
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  8. #8
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,561
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth
    echo isn't a function tho :P
    lol, logic earth! I didn't know you were that finicky
    Yeah that little PHP language construct has been very handy though, my lord!

  9. #9
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    if(preg_match('/win/i'PHP_OS))
        
    $cmd "dir /b/s *.php";
    else
        
    $cmd "find -name *.php";

    $funcs array_merge(
        
    reset(get_defined_functions()),
        
    explode(",""array,list,echo,print,unset,isset,empty,include,include_once,require,require_once")
    );

    $files explode("\n"trim(`$cmd`));
    foreach(
    $files as $file) {
        
    preg_match_all("~(\w+)\s*\(~"file_get_contents($file), $m);
        
    $counts array_count_values($m[1]);
        foreach(
    array_intersect($funcs$m[1]) as $funcname)
            @
    $calls[$funcname] += $counts[$funcname];
    }

    $fmt "%25s %5d\n";

    printf($fmt"FILES"count($files));
    printf($fmt"CALLS"array_sum($calls));

    arsort($calls);
    foreach(
    $calls as $func => $cnt)
        
    printf($fmt$func$cnt);
    Top20 for a medium-sized project:

    Code:
                        FILES    89
                        CALLS  2554
                        array   699
                       strlen   122
                        count   105
                        isset    84
                       define    74
                       intval    68
                       strpos    66
                      explode    48
                   preg_match    48
                   user_error    46
                        unset    45
                 preg_replace    45
                         trim    40
                      implode    39
                       substr    37
                     is_array    35
                         list    29
                         date    23
                        reset    21


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •