Archived Boards and Threads... > Parham's PHP Tutorials

PHP Lesson 07 - control structure, if statement

<< < (3/3)

Seph|roth:
catqueen, how come your post count states "0"? ;) weird....

catqueen:

--- Quote from: Seph|roth on September 08, 2003, 07:40:44 PM ---catqueen, how come your post count states "0"? ;) weird....

--- End quote ---
I hadn't even noticed. That is weird.

[Unknown]:
This board was set to have posts not count.

-[Unknown]

Joey Smithâ„¢:

--- Quote from: Parham on September 01, 2003, 01:57:39 AM ---[Unknown] made a very good point.  With assignment, variables themselves aren't referenced, instead their values are copied.


--- Code: ---$red = 'red';
$box = $red;
$red = 'blue';

echo $box; //will print red

--- End code ---

while


--- Code: ---$red = 'red';
$box = &$red;
$red = 'blue';

echo $box; //will print blue

--- End code ---

To pass a variable by reference (and not just copy the value), you HAVE to add an ampersand in front of the variable.  I think this discussion itself might make a very good lesson.

--- End quote ---
So let me get this straight here....

In this example:
$red = 'red';
$box = $red;
$red = 'blue';

echo $box; //will print red

echo $red; //would output blue because it was reassigned in the last line right?

Navigation

[0] Message Index

[*] Previous page

Go to full version