1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

isset and foreach

Discussion in 'PHP' started by Omzy, Jan 22, 2009.

  1. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #21
    Simply put....

    [boolean expression] ? [if true] : [if false]

    Where the boolean expression is anything that can evaluate to true or false (non-strict type checking.)

    Dan.
     
    Danltn, Jan 25, 2009 IP
  2. Omzy

    Omzy Peon

    Messages:
    249
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #22
    Right, I've just gone through all my scripts and had to put in a bunch of isset statements to get rid of all my undefined index errors. These were mainly due to 'no such $_GET variable' and other little things like that.

    Is it even important to fix these errors even though the script runs fine and won't display an error unless error reporting is turned on?
     
    Omzy, Jan 25, 2009 IP
  3. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #23
    IMO yes, increases portability, makes debugging easier later on and generally makes your code more professional.

    How would you feel if you bought a script, had error_reporting fully on and found a long page of errors, and when you ask you only get the reason "We're too lazy to fix that, use this workaround to hide them."

    Worth doing.
     
    Danltn, Jan 25, 2009 IP
  4. LogicFlux

    LogicFlux Peon

    Messages:
    2,925
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #24
    I'm sure you've encountered this as I have and it's annoying as hell.
     
    LogicFlux, Jan 25, 2009 IP
    ncz_nate likes this.