Jump to content

elseif not working - any idea why?


greatbigterry

Recommended Posts

PHP newb here - apologies if the answer to this is really simple.

 

I've tried to add a geotargetting code into my website but it appears the elseif part isn't working, no matter what I do.

 

Here's the code - any idea why if is fine, and else is fine, but elseif isn't?

<?php

  if (function_exists('showCountryContentInPage')) {

    if(showCountryContentInPage(array("us", "ca"),1)) {
      // US

      $region = 'USA';
      $country = codediesel_get_users_country();
      $store_url = 'URL here';

    } elseif(showCountryContentInPage(array("at", "es", "cy", "fi", "ee", "fr", "de", "el", "ie", "it", "mt", "lu", "lv", "nl", "pt", "sk", "si", "be"),1)) {
      // Europe

      $region = 'Europe';
      $country = codediesel_get_users_country();
      $store_url = 'URL here';

    } else {
      // UK

      $region = 'UK';
      $country = codediesel_get_users_country();
      $store_url = 'URL here';

    }

    ?>
Link to comment
https://forums.phpfreaks.com/topic/292476-elseif-not-working-any-idea-why/
Share on other sites

1 - I never understand why people use function_exists.  If you are writing the code, didn't you write that function?  So why test for it?

2 - What makes you suspect a problem here?  Tell us what happens - or better yet debug your function to see what it is doing (add some echos).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.