PHP markup

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stefharley
Forum Newbie
Posts: 2
Joined: Mon Apr 14, 2008 6:10 pm

PHP markup

Post by stefharley »

I have great dificaulty remembering when i should use (brackets) when i should use {curly brackets} when i should use "quotation marks", 'quotation marks' [square brackets] etc.
I cant seem to find any documentation that explains just this. i would find it so much easier if i had reference!!

Forgive me if this is already on this forum, i just cant find it if it is!

thnx in advance if anyone can help

Stef :banghead:
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: PHP markup

Post by Chris Corbyn »

User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: PHP markup

Post by s.dot »

It's pretty easy, really.

Expressions go in brackets. Expressions are ($var), ($var == 1), ($var < 3) etc.
Code blocks require curly brackets { }.. so a simple if/else would look like this

if ($var < 3)
{
//do something here
} else
{
//do something else here
}

Strings can use either " or '

echo 'My name is Scott';
echo "My name is Scott";

However, variables can be interpreted inside double quotes only

$name = 'Scott';
echo "My name is $name";

However, you can use single quotes and concatenation

$name = 'Scott';
echo 'My name is ' . $name;

Array indexes go in brackets []

$_POST['username']
$_POST['password']
$MyArray[3]

The indexes can be treated the same as strings

$_POST["$var"]
$_POST['var' . $var]
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
stefharley
Forum Newbie
Posts: 2
Joined: Mon Apr 14, 2008 6:10 pm

Re: PHP markup

Post by stefharley »

Thnx scottayy

Just what i was looking for!

I can smile again!
Post Reply