Home Yellow Pages Movies Classifieds Jokes Jobs Free Hosting Videos




PHP Variables

All variables in PHP start with a $ sign symbol. Variables may contain strings, numbers or arrays.

Below, the PHP script assigns the string "Hello World" to a variable called $txt :

<html>
<body>
<?php
$txt="Hello World";
echo $txt;
?>
</body>
</html>

To concatenate two or more variables together, use the dot (.) operator.

<html>
<body>
<?php
$txt1="Hello World";
$txt2="1234";
echo $txt1 . " " . $txt2 ;
?>
</body>
</html>

The output of the script above will be: "Hello World 1234".

Variable Naming Rules

A variable name must start with a letter or an underscore "_".

A variable name can only contain alpha-numeric characters and underscores (a-Z, 0-9, and _ ).

A variable name should not contain spaces. If a variable name should be more than one word, it should be separated with underscore ($my_string) or with capitalization ($myString).


Back to Home
BizHat.com   Bookmark   Astrology   Chat Room   Classifieds   Computer   Downloads   Directory   Dating   Domain Tools   Education   eCards   Finance   Forums   Freelance Work   Free Hosting   Free Mail   Gallery   Games   Guest Book   Greeting Cards   Ham Radio   Health   Home Business   Hosting Tutorials   Hosting Directory   India   Jobs   Jokes   Kerala   Matrimonial   Music   Movies   News   News Letter   Recipes   Real Estate   Search   SMS   Tourist Guide   Top 100 Sites   Vote Us   Yellow Pages   Arthunkal Church   Site Map  

Google