SitePoint Sponsor

User Tag List

Page 1 of 3 123 LastLast
Results 1 to 25 of 56
  1. #1
    Spacebug Beansprout's Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    464
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    The *worst* function ever created?

    PHP has tons and tons and tons of functions for a huge range of things. Most of which are really useful.

    So, inspired by another thread where someone said addslashes() is the worst function ever created, which function do you think is the worst, or least useful, in any PHP version?

    I'm trying to think of a function I really dislike but I can't, so perhaps this is a silly thread...but we'll soon find out
    Thermal Degree - web design with standards! (View our portfolio)
    Vidahost - shared and reseller linux hosting with real support
    Use my free file uploader!
    5.99 .com/net/org/biz/us/name domains; 2.99 .info!

  2. #2
    SitePoint Enthusiast willthiswork's Avatar
    Join Date
    Feb 2003
    Location
    italy
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    beingBored();

    That's the ugliest for sure....

  3. #3
    SitePoint Evangelist Scheisskopf's Avatar
    Join Date
    Nov 2004
    Location
    Southampton, UK
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Search the boards for oogle_google...

    I think that's the most illegal function i have ever made

  4. #4
    Non-Member coo_t2's Avatar
    Join Date
    Feb 2003
    Location
    Dog Street
    Posts
    1,819
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    I think the original poster is talking about PHP's built-in functions, correct?

  5. #5
    SitePoint Addict n0other's Avatar
    Join Date
    Feb 2005
    Posts
    290
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP has everything for my needs, other way I wouldn't use it. That means it has all the functions I need, other way I wouldn't use it. That means I can't think of a function I hate also (is that a bad thing?). Maybe some egzotic programmers have something to say, the ones who use egzotic databases, ldap thing (yes, I'm too lazy to read that up) or do lots of xml processing.

  6. #6
    SitePoint Wizard
    Join Date
    Jan 2004
    Location
    3rd rock from the sun
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wish they'd rename print_r() to :

    wtf()

  7. #7
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paulyG
    I wish they'd rename print_r() to :

    wtf()
    PHP Code:
    <?php
    function wtf($a)
    {
         
    print_r($a);
    }
    ?>

  8. #8
    Non-Member Commander Cobra's Avatar
    Join Date
    Sep 2005
    Location
    us
    Posts
    271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I hate typing out:

    get_magic_quotes_gpc()

  9. #9
    Non-Member coo_t2's Avatar
    Join Date
    Feb 2003
    Location
    Dog Street
    Posts
    1,819
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Commander Cobra
    I hate typing out:

    get_magic_quotes_gpc()
    Ask Vinnie if you can have a copy of his ScrewYouMagicQuotesGPC class.

  10. #10
    Non-Member Commander Cobra's Avatar
    Join Date
    Sep 2005
    Location
    us
    Posts
    271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Heh, does it have methods like?

    Code:
    $ScrewYouMagicQuotesGPC->AreThemDamnMagicQuotesGetPostCookieTurnedOnRightNow()

  11. #11
    SitePoint Guru
    Join Date
    Jun 2002
    Posts
    616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mysql_real_escape_string is a real hassle to type over and over, you'd think they'd come up with a more concise name for something that's supposed to be used so much. Something like mysql_escape() would be better.

  12. #12
    Spacebug Beansprout's Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    464
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ticksoft
    mysql_real_escape_string is a real hassle to type over and over, you'd think they'd come up with a more concise name for something that's supposed to be used so much. Something like mysql_escape() would be better.
    function e($v){return mysql_real_escape_string($v);}

    Short enough?
    Thermal Degree - web design with standards! (View our portfolio)
    Vidahost - shared and reseller linux hosting with real support
    Use my free file uploader!
    5.99 .com/net/org/biz/us/name domains; 2.99 .info!

  13. #13
    Non-Member Commander Cobra's Avatar
    Join Date
    Sep 2005
    Location
    us
    Posts
    271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, what I've thought about doing it just calling it once:

    Code:
    if get_magic_quotes_gpc() die('turn off magic quotes gpc!');
    
    // db stuff...
    $var=pg_escape_string($var);
    and turn off magic quotes in httpd's config (a php_set_value or something in VirtualHost).

  14. #14
    SitePoint Wizard Young Twig's Avatar
    Join Date
    Dec 2003
    Location
    Albany, New York
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dylan B
    PHP Code:
    <?php
    function wtf($a)
    {
         
    print_r($a);
    }
    ?>
    That's really not a bad idea. I'm about to make a wtf() function like this:

    PHP Code:
    function wtf($pos)
    {
          echo 
    '<pre>';
          
    var_dump($pos);
          echo 
    '</pre>';

    That will save me so much time.

  15. #15
    Non-Member coo_t2's Avatar
    Join Date
    Feb 2003
    Location
    Dog Street
    Posts
    1,819
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Commander Cobra
    Heh, does it have methods like?

    Code:
    $ScrewYouMagicQuotesGPC->AreThemDamnMagicQuotesGetPostCookieTurnedOnRightNow()
    Virtually identical, except his method names produce stars (*) when posted on this forum.
    But the method names of that class are still pretty tame compared to the method names of his ScrewYouMysqlEscapeFunctions class.

  16. #16
    Non-Member Commander Cobra's Avatar
    Join Date
    Sep 2005
    Location
    us
    Posts
    271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Related to function names, I've done some incredibly deep thinking about underscores vs. studly caps:

    functionName - 13 keystrokes
    function_name - 14 keystrokes

    Therefore I like studly caps best from a laziness perspective, but I think underscores are easier to read.

  17. #17
    Non-Member Commander Cobra's Avatar
    Join Date
    Sep 2005
    Location
    us
    Posts
    271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Beansprout
    function e($v){return mysql_real_escape_string($v);}

    Short enough?
    Heh, now we're getting like Perl. It has a bunch of wonderfully named varialbles like $_, $@, ...

  18. #18
    Awesome Addict
    Join Date
    Mar 2004
    Location
    Toronto, Canada
    Posts
    326
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Beansprout
    So, inspired by another thread where someone said addslashes() is the worst function ever created ...
    Huh? Can you provide a link to that thread? I'd like to know why ...

  19. #19
    SitePoint Addict n0other's Avatar
    Join Date
    Feb 2005
    Posts
    290
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Heh, seems like somebody here needs an editor with autocompletion feature

  20. #20
    SitePoint Wizard HarryR's Avatar
    Join Date
    Dec 2004
    Location
    London, UK
    Posts
    1,376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Commander Cobra
    Heh, now we're getting like Perl. It has a bunch of wonderfully named varialbles like $_, $@, ...
    There's nothing wrong with that, and it all starts to make sense after a good few cans of beer

    Anyway, my vote for the 'most useless PHP function' award goes to sql_regcase:
    http://www.php.net/manual/en/function.sql-regcase.php

    Wtf is the the sql_ prefix? Can't it just have a nice 'normal' name like ereg_create_nocase (or atleast something that'll go along with the standard naming conventions).

    Edit:


    Regex equivilent: s/\([a-zA-Z]\)/\[\U\1\L\1\E\]/g

  21. #21
    Non-Member Commander Cobra's Avatar
    Join Date
    Sep 2005
    Location
    us
    Posts
    271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One of the worst functions I've ever seen is foo(). I've seen it used all over the place and I've never been able to really figure out what it does! It seems to be implemented in lots of languages too! It seems similar to other functions like bar() and baz(). I can't figure out what those functions do either.

  22. #22
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The worst php function is empty

  23. #23
    Non-Member Commander Cobra's Avatar
    Join Date
    Sep 2005
    Location
    us
    Posts
    271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use empty. Should probably use isset() instead.

  24. #24
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    273
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dylan B
    PHP Code:
    <?php
    function wtf($a)
    {
         
    print_r($a);
    }
    ?>

    NOW THAT WAS FUNNY

  25. #25
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    Sutton, Surrey
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Commander Cobra
    Related to function names, I've done some incredibly deep thinking about underscores vs. studly caps:

    functionName - 13 keystrokes
    function_name - 14 keystrokes

    Therefore I like studly caps best from a laziness perspective, but I think underscores are easier to read.
    If underscores are easier to read then they should always be the first choice.

    "Programs must be written for people to read, and only incidentally for machines to execute."
    -- Abelson and Sussman


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
  •