PHP and MySQL Basics: Assigning and Using Variables
Assigning a value to PHP variable is very easy, you can use the assignment operator ( = ) to store values into a php variable. refer below for example.
<html> <head> <title>Assigning Values to PHP Variable</title> </head> <body> <?php //this is how you assign a value to a php variable $age = 20; //To use the variable $age, simply call its name and PHP will substitute its value at runtime. //this is how you use a php variable echo "I am now $age years old"; ?> </body> </html>
copy and paste the code above to your text editor and save it as variable.php then run it on your localhost.
you should get this output..
Tags: PHP, PHP Tutorials



Hi everyone im 






October 7th, 2008 at 8:02 am
Wow..Ang galing, ganda ng theme mo bro! ;)
Reply
Daniel (79 comments.) Reply:
October 7th, 2008 at 1:34 pm
thanks tol hehe bunga ng experimento ko sa css at photoshop to’ hehe
Reply
October 15th, 2008 at 12:23 am
I guess it could help someone get started… Maybe you could take it a little further and explain how to get them from $_GET, and also how to concatenate using .= and maybe even some +=, ++ action.
=)
Reply
Daniel Dumas (79 comments.) Reply:
October 15th, 2008 at 1:15 am
yeah we’ll get into that hehe this section is just an introduction on how to assign and use php variables for a total beginner, i have a section for php global variables. i will compile this tutorial into one page when i finished this. .thanks for comment hehe
Reply