Jump to content

Php Conditionals Not Working As Expected In Jquery Mobile.


drayarms

Recommended Posts

I'm building a site with both jQuery mobile and native HTML5. I send a PHP cookie named "language" from the site to the browser to and assign it a value of either "english" or "spanish" depending on user input. Then I use the function below to output all content on the site in the language chosen

 


<?php

function translate ($english_txt,$spanish_txt){

switch ($_COOKIE['language']){

case "english":

echo $english_txt;

break;

case "spanish":

echo $spanish_txt;

break;

default:

echo $english_txt;

}//End of switch


}//End of translate function

?>

 

Here is example of a paragraph printed on the website using this fucntion

 

<p> <?php translate("Happy New Year","Feliz Navidad"); ?> </p>

 

Everything works just fine on the HTML site. With the jQM site however, only the default case is echoed. But I do know for a fact that the cookie exists (I used the isset funtion to verify that) and I also know for a fact that the value of the cookie is either "spanish" or "english" depending on the user input. Yet I'm puzzled as to why the conditional doesn't work in jQM. Keep in mind that it works in HTML. I also tried using the if conditional thus:

 

<?php
if($_COOKIE['language']=="english"){echo "Happy New Year";}
if($_COOKIE['language']=="spanish"){echo "Feliz Navidad";}
?>

 

to no avail. Anyone can tell me what I'm not doing right?

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.