Hello there im new to php and for some reason im having trouble with the String variables, every time i change the $light variable it doesn't = the supposed String and just always echo's "stop".

<html> <head> <title> Conditional Statement Practice </title> </head>
<body>
<?php 
 extract($_GET);

 /* Put your PHP code in here */
 $light="orange";
 
 if($light="red"):
 	echo "stop";
 elseif($light="orange"):
 	echo "prepare to stop";
 elseif($light="green"):
 	echo"proceed";
 endif;

?>
</body>
</html>

Oh i feel silly ==

<html> <head> <title> Conditional Statement Practice </title> </head>
<body>
<?php 
 extract($_GET);

 /* Put your PHP code in here */
 $light="green";
 
 if($light=='red'):
 	echo "stop";
 elseif($light=='orange'):
 	echo "prepare to stop";
 elseif($light=='green'):
 	echo"proceed";
 endif;

?>
</body>
</html>
Member Avatar for diafol

Common mistake. Mark this post as solved though, it'll stop others from investigating.

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.