Bad Code

by 6 replies
8
Does anyone see the error in this snippet?

PHP Code:
function get_phone_number() {

if (isset(
$_COOKIE['Believe_Adwords'])) echo "555-0968-5566";

else echo 
"555-8979-4567";


I'm getting:

I got the code from this site and I've tried both the way it was written $_COOKIE['Believe_Adwords] and the way I thought it should be written $_COOKIE['Believe_Adwords'] both without success.

Any input is appreciated!
#programming #bad #code
  • Banned
    Looks like you are missing some {} in your if statement.
    • [1] reply
    • I never understood ones need to avoid braces so much. I notice a lot of coders coming over from other languages do it a lot.
  • Banned
    [DELETED]
    • [1] reply
    • function get_phone_number()
      {
      if (isset($_COOKIE['Believe_Adwords'])) {
      echo "555-0968-5566";
      } else {
      echo "555-8979-4567";
      }
      }
      • [ 1 ] Thanks
      • [1] reply

Next Topics on Trending Feed