> > --- sourabh kulkarni <[EMAIL PROTECTED]> wrote:
> >> can anybody let me know what is $$ in php and where it is 
> >> used?
> >>    
> >>   Thanks,
> >>   Sourabh


> James Keeline wrote:
> > The $$ before a variable name indicates that it is a dynamic 
> > variable.  Specifically, the actual name of the variable 
> > being referred to is the contents of another variable.
> >
> > A simple example of use is:
> >
> > $X = "banana";
> > ${$X} = "ice cream";
> > print ${$X}; // displays "ice cream"
> >
> > In this example, $X holds a word.  The ${$X} or $$X takes the 
> > content of $X and uses it as a variable name which can be set 
> > or used in another expression such as print.


--- Skylinux <[EMAIL PROTECTED]> wrote:

> Now what's the difference between the above and this:
> $X = "banana";
> $X = "ice cream";
> echo($X); // displays "ice cream"
> 
> -- 
> Skylinux
> Computer and Robotic Research
> http://www.network-technologies.org


In your example you have simply reassigned the variable $X with a new value.

In my example the variable $X holds the *name* of a variable.  The $$X or ${$X}
takes the *name* of the variable which can be set as the program is running.

// variable name
$X = "banana";

${$X} = 123;

The second statement is equivalent to coding:

${"banana"} = 123;

or

$banana = 123;

It's a subtle concept, I'll admit.  It can be difficult to grasp initially. 
However, when you need it, few alternatives will work as well.

James
_____


James D. Keeline
http://www.Keeline.com  http://www.Keeline.com/articles
http://Stratemeyer.org  http://www.Keeline.com/TSCollection

http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Fall Semester Begins Sep 7 -- New Classes Start Every Few Weeks.


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/2jUsvC/tzNLAA/TtwFAA/HKFolB/TM
--------------------------------------------------------------------~-> 

Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to