php-general Digest 7 Mar 2011 08:17:51 -0000 Issue 7215

Topics (messages 311718 through 311726):

Re: $$var
        311718 by: tedd
        311719 by: Mujtaba Arshad
        311724 by: NetEmp

Re: Delaying $(document).ready() in jQuery until php script finish
        311720 by: Ellis Antaya
        311721 by: Ellis Antaya

Re: $GLOBALS example script on php.net
        311722 by: FeIn
        311725 by: Ashim Kapoor
        311726 by: FeIn

Re: Is 5.3.5 really that much slower than 5.2?
        311723 by: Andrew Mason

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
At 6:42 PM +0530 3/6/11, Ashim Kapoor wrote:
Dear All,

I was reading the php manual for session_register, and I found the following
line there : -


$_SESSION[$var] = $$var;

Why do I need $$ there ? Can someone explain?

Thank you,
Ashim

Ashim:

You don't need to user session_register().

Cheers,

tedd


--
-------
http://sperling.com/

--- End Message ---
--- Begin Message ---
If $a = 'foo'
and $$a = nothing (i.e. no value assigned to $foo) you will get an error if
you tried to use this to do something else.

On Sun, Mar 6, 2011 at 3:21 PM, tedd <tedd.sperl...@gmail.com> wrote:

> At 6:42 PM +0530 3/6/11, Ashim Kapoor wrote:
>
>> Dear All,
>>
>> I was reading the php manual for session_register, and I found the
>> following
>> line there : -
>>
>>
>> $_SESSION[$var] = $$var;
>>
>> Why do I need $$ there ? Can someone explain?
>>
>> Thank you,
>> Ashim
>>
>
> Ashim:
>
> You don't need to user session_register().
>
> Cheers,
>
> tedd
>
>
> --
> -------
> http://sperling.com/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Mujtaba

--- End Message ---
--- Begin Message ---
As per my experience so far, there is no such depth limit existing. The only
limit is imposed by the system resources (like script execution time etc.)
but not by PHP.

Cheers
NetEmp

On Sun, Mar 6, 2011 at 8:42 PM, shiplu <shiplu....@gmail.com> wrote:

> Just being curious, I have a question.
> How many times PHP interpreter will replace this variables? I mean how deep
> it will be?
>
> If I use variable variables like
>
> $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$a
> how long it will be evaluated?
>
> --
> Shiplu Mokadd.im
> My talks, http://talk.cmyweb.net
> Follow me, http://twitter.com/shiplu
> Innovation distinguishes between follower and leader
>

--- End Message ---
--- Begin Message ---
i'm not sure i understand your problem ?!?

php runs on the server, delivers html code and/or javascript to the browser
and only from there the jQuery will execute it's main loop and start trigger
some events such as the ready event.  So the php script is always finish
when javascript start to execute ...


On Fri, Mar 4, 2011 at 12:18, Nathan Rixham <nrix...@gmail.com> wrote:

> Richard Sharp wrote:
>
>> I have been banging my head trying to figure out how to delay
>> $(document).ready() command until my php script finish running and load
>> data into a csv file.  Any ideas
>>
>
> *which* PHP script? are you returning an HTML document then keeping the
> script going in the background, /or/ are you requesting another script (by
> js, clicking a link, posting a form), /or/?
>
> I know it's a jQuery question, but it might be a PHP related gotcha.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Ellis
1100101000111101

twitter.com/floverdevel
facebook.com/ellis.antaya
google.com/profiles/ellis.antaya
linkedin.com/in/ellisantaya

--- End Message ---
--- Begin Message ---
Also, the $(document).ready() is triggered when the DOM is ready to be
manipulated.
I dont know why you would consider alter the behavior of this event, maybe
what you want is to create yourself a custom event handler ...

On Sun, Mar 6, 2011 at 21:43, Ellis Antaya <ellis.ant...@gmail.com> wrote:

> i'm not sure i understand your problem ?!?
>
> php runs on the server, delivers html code and/or javascript to the browser
> and only from there the jQuery will execute it's main loop and start trigger
> some events such as the ready event.  So the php script is always finish
> when javascript start to execute ...
>
>
> On Fri, Mar 4, 2011 at 12:18, Nathan Rixham <nrix...@gmail.com> wrote:
>
>> Richard Sharp wrote:
>>
>>> I have been banging my head trying to figure out how to delay
>>> $(document).ready() command until my php script finish running and load
>>> data into a csv file.  Any ideas
>>>
>>
>> *which* PHP script? are you returning an HTML document then keeping the
>> script going in the background, /or/ are you requesting another script (by
>> js, clicking a link, posting a form), /or/?
>>
>> I know it's a jQuery question, but it might be a PHP related gotcha.
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> Ellis
> 1100101000111101
>
> twitter.com/floverdevel
> facebook.com/ellis.antaya
> google.com/profiles/ellis.antaya
> linkedin.com/in/ellisantaya
>
>


-- 
Ellis
1100101000111101

twitter.com/floverdevel
facebook.com/ellis.antaya
google.com/profiles/ellis.antaya
linkedin.com/in/ellisantaya

--- End Message ---
--- Begin Message ---
Unsetting doesn't leave user defined variables. Unsetting simply destroys
variables (or removes elements from an array, etc). There is nothing magic
or hidden in that script. I think the note meant exactly what it said: after
creating a local copy of the $GLOBALS array and removing super globals from
it, all that's left in it are user defined variables. And that's exactly
what gets returned from the function.

On Sun, Mar 6, 2011 at 5:11 PM, Ashim Kapoor <ashimkap...@gmail.com> wrote:

> It doesn't though, it creates a copy of the $_GLOBALS super global array,
> removes entries that will have been set by the system (i.e. it leaves
> user-defined variables) and then returns the ones that are left, so in
> that,
> the user note is perfectly correct.
>
> What has me puzzled is how unsetting LEAVES user defined variables ? Why
> would that happen ?
>
> The array in the function lists the common server-defined variables
> > (HTTP_VARS, etc), which it unsets from the local copy of the super global
> > array ($globals). Basically, it loops through the un-named array, and
> unsets
> > that index from $globals.
> >
>
> Thank you,
> Ashim
>

--- End Message ---
--- Begin Message ---
Unsetting doesn't leave user defined variables. Unsetting simply destroys
> variables (or removes elements from an array, etc). There is nothing magic
> or hidden in that script. I think the note meant exactly what it said: after
> creating a local copy of the $GLOBALS array and removing super globals from
> it, all that's left in it are user defined variables. And that's exactly
> what gets returned from the function.



This is a script vars.php

<?php
function globals() {
    $globals = $GLOBALS;
    print_r("Before...");
    print_r($globals);
    foreach (array(
        'GLOBALS',
        '_ENV',
        'HTTP_ENV_VARS',
        '_POST',
        'HTTP_POST_VARS',
        '_GET',
        'HTTP_GET_VARS',
        '_COOKIE',
        'HTTP_COOKIE_VARS',
        '_SERVER',
        'HTTP_SERVER_VARS',
        '_FILES',
        'HTTP_POST_FILES',
        '_REQUEST'
    ) as $var) {
        unset($globals[$var]);
    }
    print("<br />After...");
       print_r($globals);

    return $globals;
}

globals();
?>

I called http://localhost/vars.php?a=1

I get : -

Before...Array ( [GLOBALS] => Array *RECURSION* [_POST] => Array ( ) [_GET]
=> Array ( [a] => 1 ) [_COOKIE] => Array ( ) [_FILES] => Array ( ) )
After...Array ( )

ALL the variables are UNSET. I have a user defined $_GET[a] but that goes
away too.

One second, what do you mean by user defined variables? Maybe I am lost in
comprehension

--- End Message ---
--- Begin Message ---
I am unable to provide a better definition that "user defined variables".
User defined variables are variables that are declared by the user. User
here means the creator (or maintainer of the script).

So for:

<?php
$a = 'A';
$b = 'B';
$c = 'C';

function globals() {
    $globals = $GLOBALS;
    print_r("Before...");
    print_r($globals);

    foreach (array(
        'GLOBALS',
        '_ENV',
        'HTTP_ENV_VARS',
        '_POST',
        'HTTP_POST_VARS',
        '_GET',
        'HTTP_GET_VARS',
        '_COOKIE',
        'HTTP_COOKIE_VARS',
        '_SERVER',
        'HTTP_SERVER_VARS',
        '_FILES',
        'HTTP_POST_FILES',
        '_REQUEST'
    ) as $var) {
        unset($globals[$var]);
    }
    print("<br />After...");
       print_r($globals);

    return $globals;
}

globals();
?>

You will get: Array( [a] = A [b] => B [c] => C ). $a, $b and $c are user
defined variables.


On Mon, Mar 7, 2011 at 7:54 AM, Ashim Kapoor <ashimkap...@gmail.com> wrote:

>
>
> Unsetting doesn't leave user defined variables. Unsetting simply destroys
>> variables (or removes elements from an array, etc). There is nothing magic
>> or hidden in that script. I think the note meant exactly what it said: after
>> creating a local copy of the $GLOBALS array and removing super globals from
>> it, all that's left in it are user defined variables. And that's exactly
>> what gets returned from the function.
>
>
>
> This is a script vars.php
>
>
> <?php
> function globals() {
>     $globals = $GLOBALS;
>     print_r("Before...");
>     print_r($globals);
>
>     foreach (array(
>         'GLOBALS',
>         '_ENV',
>         'HTTP_ENV_VARS',
>         '_POST',
>         'HTTP_POST_VARS',
>         '_GET',
>         'HTTP_GET_VARS',
>         '_COOKIE',
>         'HTTP_COOKIE_VARS',
>         '_SERVER',
>         'HTTP_SERVER_VARS',
>         '_FILES',
>         'HTTP_POST_FILES',
>         '_REQUEST'
>     ) as $var) {
>         unset($globals[$var]);
>     }
>     print("<br />After...");
>        print_r($globals);
>
>     return $globals;
> }
>
> globals();
> ?>
>
> I called http://localhost/vars.php?a=1
>
> I get : -
>
> Before...Array ( [GLOBALS] => Array *RECURSION* [_POST] => Array ( ) [_GET]
> => Array ( [a] => 1 ) [_COOKIE] => Array ( ) [_FILES] => Array ( ) )
> After...Array ( )
>
> ALL the variables are UNSET. I have a user defined $_GET[a] but that goes
> away too.
>
> One second, what do you mean by user defined variables? Maybe I am lost in
> comprehension

--- End Message ---
--- Begin Message ---
> Is anyone else out there in the same boat?

Actually we have found the complete opposite so there might be some
people who are in the same boat as you but certainly not all.

Andrew

--- End Message ---

Reply via email to