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

PHP Lesson 07 - control structure, if statement

<< < (2/3) > >>

[Unknown]:

--- Quote from: Overseer on September 05, 2003, 07:41:01 AM ---what about dereferencing? is it the same as in C?

e.g.

$Red = 'red';
$pRed = &$Red;
$RedToo = *$pRed;  <-- probably wrong :)

--- End quote ---

No, it's like this:

$Red = 'red'; // $Red == 'red' -> true.
$pRed = &$Red; // $pRed == 'red' -> true - this is not a C++ reference, it's more link a shortcut.
$RedToo = $pRed; // $RedToo == 'red' -> true.
$pRed = 'blue'; // $Red == 'blue' -> true, $RedToo == 'blue' -> false.

-[Unknown]

catqueen:
Does PHP have a version of the select case/switch statement?

In C++ it would be

--- Code: ---switch(variable)
 {
   case 1:
   //first selection
   break;
   case 2:
   //second selection
   break;
   default:
   //if nothing else matches
 }

--- End code ---

Usually, elseif is sufficient, but sometimes the switch comes in handy.

[Unknown]:
Yes, and it has exactly the same syntax.

-[Unknown]

Overseer:
ahh cool.. i had wondered that.. i'd seen lots of if /elseif/elseif.. and thought.. ewww  ;D

catqueen:

--- Quote from: [Unknown] on September 08, 2003, 12:58:57 PM ---Yes, and it has exactly the same syntax.
--- End quote ---

I thought it might. I think jscript uses the same syntax also. That's one of the good things about learning C type languages.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version