Jump to content

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).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.