tags:

views:

61

answers:

3

as above when a user is logged into my website, I want it to say hello or welcome "user"

i'm using the code below:

 [code]      
 <?php
 $user = $_GET['session_is_registered'];
 echo ('$user'); 
 ?>
 [/code]       

but the php just displays "$user"

what am I doing wrong?

thanks

+1  A: 

When using ' single quotes, it means literal. You don't need any quotes.

 echo $user;

Thats it.

Laykes
+2  A: 

Use double quotes if you want to evaluate $user variable inside a string. Otherwise just use:

echo $user;

As other answers have already stated.

Pablo Santa Cruz
Or use inline temp (http://www.refactoring.com/catalog/inlineTemp.html) to remove the temp variable "$user", possibly using curly braces to use the array reference within a double quoted string.
Ewan Todd
+5  A: 

just use

echo $user;

echo is a keyword, not a function, so you don't need the parenthesis. Also, to evaluate variables inside a string you need to use double quotation marks e.g. echo "Hello, $user";. If you're just using the variable on its own you don't need the quotation marks at all.

echo $user;
echo 'Hello, ' . $user;
echo "Hello, $user.  Your last visit was $lastVisitDate.";
Andy E
ah excellent, i'll try that out!
Adam