SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Not yet perfect mattalexx's Avatar
    Join Date
    Oct 2005
    Location
    Taos, NM, US
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Debugging someone else's code

    AHHH!!!!!
    PHP Code:
    $action = (array_key_exists("action"$_GET))?$_GET["action"]:((array_key_exists("action"$_POST))?$_POST["action"]:"display_all"); 
    When's five o'clock?
    Matt Alexander
    Alexander Site Design

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    take "action" and beat them silly with a club.

  3. #3
    Not yet perfect mattalexx's Avatar
    Join Date
    Oct 2005
    Location
    Taos, NM, US
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by clamcrusher View Post
    take "action" and beat them silly with a club.
    Looks a bit like a club, huh?
    Matt Alexander
    Alexander Site Design

  4. #4
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not too sure what your problem is, but I;m guessing you are having probs reading their code lets make it look nicer

    PHP Code:

    if ( array_key_exists("action"$_GET) )
    {
        
    $action $_GET["action"];
    }
    elseif ( 
    array_key_exists("action"$_POST ) )
    }
        
    $action $_POST["action"]
    }
    else
    {
        
    $action "display_all";

    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  5. #5
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And array_key_exists("action", $_GET) can be written as isset($_GET["action"])

  6. #6
    Not yet perfect mattalexx's Avatar
    Join Date
    Oct 2005
    Location
    Taos, NM, US
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mythix View Post
    Not too sure what your problem is, but I;m guessing you are having probs reading their code lets make it look nicer
    I can read it. I was just facing lines and lines of this ******** code and it was making me nuts. It was wading through molasses.
    Matt Alexander
    Alexander Site Design

  7. #7
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    looool

    Had the same problem recently was given a tonne of ancient Perl scripts to 'update' - took about an hour of looking at them to realise there wasn't any point in touching them, started from scratch instead

    Unfortunatley they wudn't let me rewrite them in PHP, basically cos the guy who maintained them cudnt be arsed to upgrade any of his skill sets. Whats even more annoying is he is the technical director of a division in a very big IT company. A. why is he maintaing the scripts anyway, isn;t he supposed to be provding technical support to projects? B. he had never come accross OOP (so how can he be technical dorector?)

    damn smelly company. (I won't mention its name... for now lol)
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  8. #8
    Not yet perfect mattalexx's Avatar
    Join Date
    Oct 2005
    Location
    Taos, NM, US
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mythix View Post
    damn smelly company. ...
    Funny you say that... The kid who originally wrote that code was fired from the company because he refused to bathe more than once a week.

    Quote Originally Posted by Dr. Bronner
    Cleanliness is next to Godliness
    Matt Alexander
    Alexander Site Design


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
  •