06- PHP Variables

0
496

This tutorial is all about 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.
Syntax:
$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. PHP Syntax
  2.  
  3. <!--?php &lt;br ?--> $str1 = "PHP Programming";
  4. $str2=" is fun!";
  5. echo $str1.' ' .$str2;
  6.  
  7. echo '';
  8.  
  9. $intvar = 37;
  10.  
  11. echo $intvar;
  12. ?&gt;

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

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.

 

Readers might read also:

 

 

Facebook Comments
(Visited 48 times, 1 visits today)
SHARE
Previous article05- PHP echo
Next article07- PHP Constants
Hello Itsourcecoders, welcome to itsourcecode.com. I'm Joken Villanueva, MIT a passionate Blogger, Programmer and a Hobbyist. I started Itsourcecode because I wanted to give back and Share all the learnings and knowledge I've learned in my career and I believe through this website I would be able to help and assist those newbie programmers in enhancing their skills from different programming languages. So let us all help each other by sharing our ideas!

LEAVE A REPLY

Please enter your comment!
Please enter your name here