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..

assigning values to php variables

Share and Bookmark this Post..

  • Digg
  • Yahoo! Buzz
  • Twitter
  • Facebook
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Technorati
  • Reddit
  • Sphinn
  • MySpace
  • Slashdot
  • BlinkList
  • Live
  • Mixx
  • NewsVine
  • Yahoo! Bookmarks
  • Ratimarks
  • LinkedIn





Tags: ,

4 Responses to “PHP and MySQL Basics: Assigning and Using Variables”




Leave a Reply

This blog will make your link do follow after you leave 5 comments. i check every comment posted and reply to each also. please do not spam i hate spam, there is no room for spam here in my blog thanks!

CommentLuv Enabled
:argh: :| :$ :B :cool: :*( :curious: x_x :gasp: =D :happy: :/ :D :injured: :lol: :lol2: :love: :X :meh: O_o :ohhyeahh: D: :omg: :raisebrow: :P :( 0_0 :shocked: :sly: :) :] ;] :worry: :wow:

Subscribe to feed

this blog use Comment Luv

Featured Post


Make your Wordpress URL Search Engine Friendly
Simple steps to make your wordpress url search engine friendly..


Give some luv with comment luv
This blog is now comment luv powered..


Fix Wordpress PHP fatal error memory size exhauster
Ways on how to solve PHP fatal error or PHP memory limit on wordpress blogs anr other opensource web apps..


Download Norton Antivirus Internet Security for free
Read this post to know how you can download a free norton antivirus or internet security..


Sponsored Links


 10 Users Online