Sometimes I am TRWTF.



  • So I'm finding that one page of a site I'm working on, hangs. It only happens locally, not online (thank goodness). I'm working with PHP4 so I can't get XDebug and stuff, this is legacy code so no logging or anything. So what do I do? I put an exit('test'); statement in and move it around. Finally, I come to the point where I find out that this doesn't hang:

        exit('test');
        if (extension_loaded('curl'))
        {
            // do stuff
        }
        else
        {
            // do other stuff
        }
    

    And this does:

        if (extension_loaded('curl'))
        {
            exit('test');
            // do stuff
        }
        else
        {
            // do other stuff
        }
    

    My conclusion: HOLY SHIT the extension_loaded function hangs my site! So I spend about half an hour googling, before realizing the problem is inside the else clause. Can I hand my programming license please? :(



  • @toon said:

    PHP4

    TRWTF. Unsupported for at least 5 years, maybe even 13 years.

    PHP is bad enough but am ancient one would drive me to ragequit life!



  • @Zemm said:

    @toon said:
    PHP4

    TRWTF. Unsupported for at least 5 years, maybe even 13 years.

    PHP is bad enough but am ancient one would drive me to ragequit life!

    Unfortunately, I'm stuck with PHP 4 for many legacy projects. I actually think 5.2, which our PHP 5 projects use, is old. All the cool PHP people are doing stuff with namespaces. Can't do that with 5.2. If it were up to me, we'd switch to 5.4 or even 5.5.



  • @Zemm said:

    PHP
    TRWTF.



  • @mikeTheLiar said:

    @Zemm said:
    PHP
    TRWTF.

    I resent that. You're the worst.



  • Turn on output buffering

    ob_start();

    then add between every line:

    echo (LINE)."<br/>";ob_flush();

    to get the line number that worked to print out.




    Of course, for the most likely cause of a "hang"- infinite loop will give you a whole lotta numbers.... but at least you'll see where it repeats.



    Quote from the PHP docs below... I love magic!

    A few "magical" PHP constants

    LINE : The current line number of the file.



  • @darkmattar said:

    Turn on output buffering

    LINE : The current line number of the file.

    Hmm, is this just an old VB thing? I remember a VB LineNo variable that did the same thing and you had to debug the same way. Please someone send me to total recall and wipe that memory and replace it with something pleasant.



  • @KattMan said:

    @darkmattar said:
    Turn on output buffering

    LINE : The current line number of the file.

    Hmm, is this just an old VB thing? I remember a VB LineNo variable that did the same thing and you had to debug the same way. Please someone send me to total recall and wipe that memory and replace it with something pleasant.



    No idea, never created any VB code myself.

    Also, add FILE to the echo if you want the file name that line number is referencing, in cases where you have a mess of include nests.


  • Winner of the 2016 Presidential Election

    @KattMan said:

    @darkmattar said:
    Turn on output buffering

    LINE : The current line number of the file.

    Hmm, is this just an old VB thing? I remember a VB LineNo variable that did the same thing and you had to debug the same way. Please someone send me to total recall and wipe that memory and replace it with something pleasant.


    Recall creates new memories, you need Lacuna, Inc. to delete them.



  • @KattMan said:

    @darkmattar said:
    Turn on output buffering

    LINE : The current line number of the file.

    Hmm, is this just an old VB thing? I remember a VB LineNo variable that did the same thing and you had to debug the same way. Please someone send me to total recall and wipe that memory and replace it with something pleasant.

    I've used it regularly during my C++ days

    http://stackoverflow.com/questions/597078/file-line-and-function-usage-in-c



  • @bjolling said:

    @KattMan said:
    @darkmattar said:
    Turn on output buffering

    LINE : The current line number of the file.

    Hmm, is this just an old VB thing? I remember a VB LineNo variable that did the same thing and you had to debug the same way. Please someone send me to total recall and wipe that memory and replace it with something pleasant.

    I've used it regularly during my C++ days

    http://stackoverflow.com/questions/597078/file-line-and-function-usage-in-c

    __LINE__ and __FILE__ go clear back to C. Maybe farther. They've been part of the standard for a very long time.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.