Jump to content
Can't remember your login details? Read more... ×
Sign in to follow this  

Php - dead-set, absolutely easy question

Recommended Posts

I've decided to learn php, and i'm up to the conditional if statements. Never did programming before, and based on the advice of those that i've met, they've all recommended php. And so here we are.


I tried to write a conditional 'if' script. It works fine but i've defined a variable to carry a text string and i want the contents of that variable to be outputted. I'm using coda, which is for mac to preview the file.


Here's the code:


$name = "Mario";
$alpha = "what";

if ($name == "Mario") {

echo 'I am <i>$alpha<i>';



Help'll be much appreciated thanks.

Edited by Fury52

Share this post

Link to post
Share on other sites

You need to use double quotes for that syntax:



echo "I am <i>$alpha<i>";


echo 'I am <i>$alpha<i>';



If you want to use singal quotes you need to do this:


echo 'I am <i>'.$alpha.'<i>';


Have fun!



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this