Discussion:
undefined variable
Tim Streater
2014-02-20 12:25:00 UTC
Permalink
I'm doing something like this:

$PTR_fcc = isset($_POST['PTR_fcc'])==true ? $_POST['PTR_fcc'] : 0;

and possibly (maybe not, depends on some logic):

$PTR_fcc = ($fcco==0 || $mboxid==$inboxid || $mboxid==$outboxid || $mboxid==$junkboxid || $mboxid==$trashboxid) ? 0 : $mboxid;

and then later I do:

$str = "fcc: " . $PTR_fcc;

Now, upon examination it appears that I have an instance where $str ends up as:

fcc: undefined


My question is, under what conditions can a variable be set by the PHP system to the string "undefined"? Would this require that my ajax call in the browser would have to have had something explicit like:

... &PTR_fcc=undefined ...
--
Cheers -- Tim
Stuart Dallas
2014-02-20 12:28:11 UTC
Permalink
Post by Tim Streater
$str = "fcc: " . $PTR_fcc;
fcc: undefined
... &PTR_fcc=undefined …
Not explicit as such, but that is what’s happening. Javascript will use the string "undefined" whenever an undefined variable is concatenated on to a string.

-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Tim Streater
2014-02-20 12:45:00 UTC
Permalink
Post by Tim Streater
My question is, under what conditions can a variable be set by the PHP system
to the string "undefined"? Would this require that my ajax call in the
... &PTR_fcc=undefined 

Not explicit as such, but that is what’s happening. Javascript will use the
string "undefined" whenever an undefined variable is concatenated on to a
string.
Stuart,

Thanks for that - that really narrows down where I need to look.
--
Cheers -- Tim
Tedd Sperling
2014-02-20 15:02:59 UTC
Permalink
Post by Tim Streater
$PTR_fcc = isset($_POST['PTR_fcc'])==true ? $_POST['PTR_fcc'] : 0;
Try:

$PTR_fcc = isset($_POST['PTR_fcc']) ? $_POST['PTR_fcc'] : 0;

Cheers,

tedd
_______________
tedd sperling
***@sperling.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Loading...