Free Source Code and Tutorials

Custom Search

06- PHP Variables

In PHP programming, variable plays very important role wherein it allow you to store value in a computer memory such storing some text like “PHP programming is fun” or even an integer value 8. The declared variable can be used throughout your code without typing out the actual value over and over again.
$variable = specificvalue;
Take note!
In declaring PHP variable should begin with a dollar sign($) or else it will not work and it must start with letters and underscore only.Similar to other programming language, PHP does not contain spaces. And PHP Variable is also a case-sentitive, so make use the proper naming convention. For example when using a variable. The variables $personand $Person are different variables in the eyes of PHP.

  1. <html>
  2.     <head>
  3.         <title>PHP Syntax</title>
  4.     </head>
  5.     <body>
  6.         <?php
  7.             $str1 = "PHP Programming";
  8.             $str2=" is fun!";
  9.             echo $str1.' ' .$str2;
  11.             echo '</br>';
  13.             $intvar = 37;
  15.             echo $intvar;
  16.         ?>
  17.     </body>
  18. </html>

The code above will display the following.
PHP Programming is fun!

Same as code above, the variables are not declared before you can use it. Take notethat PHP does not require variables to be declared before being initialized.

Facebook Comments
(Visited 2 times, 1 visits today)
Share this

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked * © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!

%d bloggers like this: