hello friends,

What is the differnece between $name and $$name?

Recommended Answers

All 6 Replies

Well, $name is a variable while $$name is a reference variable.

$name is a variable while $$name is a reference variable.

If we define variable in Php, we use $ sign for variable.
as per the question what is difference between $ & $$. According my view single $ is a normal variable while $$ variable takes the value of a variable and treats that as name of a variable.

$fruit = 'apple';
$$fruit = 'red';
echo $fruit . ' is ' . $apple; // returns 'apple is red'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.