Re: Re: undefined variable

From: Date: Mon, 24 Mar 2014 16:11:07 +0000
Subject: Re: Re: undefined variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-323103@lists.php.net to get a copy of this message
On 03/22/2014 04:37 PM, Tim Streater wrote:
On 20 Feb 2014 at 12:28, Stuart Dallas <stuart@3ft9.com> wrote:
On 20 Feb 2014, at 12:25, Tim Streater <tim@clothears.org.uk> wrote:
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 …
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.
How about if PTR_fcc is not so much undefined on the JavaScript side, as an empty string. So that I'm passing e.g. this, via AJAX:
    ... &PTR_fcc=&myvar=27 ...
What does that mean in my PHP script when I then do:
    $PTR_fcc = isset($_POST['PTR_fcc'])==true ? $_POST['PTR_fcc'] : 0;
i.e. what value does $_POST['PTR_fcc'] have?
http://www.php.net/manual/en/function.var-dump.php is your new best friend!
-- Cheers -- Tim
-- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/

« previous php.general (#323103) next »