By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

Please help me with isset Function

P: n/a
Hi

I don't seem to understand the way isset works.

Here is some Javascript code that makes a call using PHP:

// USER CAME BACK TO CHANGE LANGUAGE
if (<?echo isset($_REQUEST["changeLanguage"])?>) {
alert("WORKS1");
desiredLanguage = "<?echo $_REQUEST["changeLanguage"]?>";
cookieIsSet = 2;
}

I am not passing any $_REQUEST["changeLanguage"] parameter!
Here is the resulting HTML page source:

// USER CAME BACK TO CHANGE LANGUAGE
if () {
alert("WORKS1");
desiredLanguage = "";
cookieIsSet = 2;
}

I thought isset should return false as it doesn't exist. Why is it
returning nothing?
Thank you for any help
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

On 15-Nov-2003, ch***********@hotmail.com (christian9997) wrote:
I don't seem to understand the way isset works.

Here is some Javascript code that makes a call using PHP:

// USER CAME BACK TO CHANGE LANGUAGE
if (<?echo isset($_REQUEST["changeLanguage"])?>) {
alert("WORKS1");
desiredLanguage = "<?echo $_REQUEST["changeLanguage"]?>";
cookieIsSet = 2;
}

I am not passing any $_REQUEST["changeLanguage"] parameter!
Here is the resulting HTML page source:

// USER CAME BACK TO CHANGE LANGUAGE
if () {
alert("WORKS1");
desiredLanguage = "";
cookieIsSet = 2;
}

I thought isset should return false as it doesn't exist. Why is it
returning nothing?


I guess it's returning null which is evaluates to false. You could add zero
to the result or use <? echo (isset(...))?'1':'0'; ?>

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #2

P: n/a
Hi,

Am 15 Nov 2003 08:44:47 -0800 hat christian9997
<ch***********@hotmail.com> geschrieben:

I thought isset should return false as it doesn't exist. Why is it
returning nothing?
Thank you for any help


isset() does return the boolean false, but echo needs a string, not a
boolean.
This is why php converts the boolean return value to a string, false
becomes "" (empty string).

btw, your JS does not make much sense: Why do you print an if expression
that will never be executed? Instead, you could include the JS code only
when it's needed.

--

Alexander M. Turek
<ra***@users.sourceforge.net>

The phpMyAdmin Project
<http://www.phpmyadmin.net>
Jul 17 '05 #3

P: n/a
Thank you to both of you for your answers they were very helpful.

"Alexander M. Turek" <al*************@stud.uni-karlsruhe.de> schrieb im
Newsbeitrag news:op**************@news.rz.uni-karlsruhe.de...
btw, your JS does not make much sense: Why do you print an if expression
that will never be executed? Instead, you could include the JS code only
when it's needed.


At the moment I am working on a sort of prototype using mostly HTML and
Javascript and only PHP when I really need it (for requests and database
access). Once I get the website working I will try and refine the code using
PHP.
As this is my first PHP project I'm not really sure of the impact PHP has on
the server performance, thats why I'm doing most of the processing on the
client side. However your observation is totally right and I hadn't actually
thought of it ;-)
Thanks
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.