PHP Data Types Variable

data type is a classification identifying one of various types of data, such as real-valued, integer or Boolean, that determines the possible values for that type.

Data type in php are very useful when we start knowing the language the first data type that we would use is “variable” a variable is symbolic representation of a value as name represent it can change or varies a variable start with a dollar sign “$” and the name of the variable.(e.g $variable = 22;) in this code i have set variable equal to an integer which is 22 and semi colon to end the statement.a variable can be written i many different ways some are as fallows






Remember these are case sensitive meaning if you write $variable and use this variable in your code and start the variable with a capital V $Variable it give an error because php doesn’t know what variable are you talking about so remember not to make this mistake.lets write an variable example code


$var1 = 3;

$var2 = 2;

echo $var1;


in the above code i created a variable $var and $var2 and set the value to 3 & 2 this code will echo or print the value that is inside in var1.

but if you write this code


$var1 = 3;

$var2 = 2;

echo $var1 . $var2;


in the above code i have added a $var1 and $var2 together with a point sign “.” this will add the value of variables and print it on the screen the output will be 5.remember this is an variable so we can change to what ever we want.

in the next example i have set the variable to an string


$var1 = “This is “;

$var2 = “String”;

echo $var1 . $var2;


this code will add the string an give the output “This is String” because we have coordinated the string.

PHP Basic Code

After Setting up the php development environment open your Operating system Text editor or you can download from the  internet which support syntax highlighting if you are using windows you can download notepad++ but if you are using MAC then you can download komodo  you can download the free version after downloading the text editor open it up and create a new PHP file to create a new php file go to the file menu and select new and choose .php after doing this you may have a new work-space for writing php code.Write this line of code <?php echo “php programming”; ?>

in this code i have use a php tag (<?php?>) remember php code is written in side a php tag,in side the tag i have written echo which will echo it back to screen and inside quotes i have written a string which is php programming and semicolon which means the end of the statement so save the file in WWW directory(if you don’t where is www directory it is located in C:/Wamp/WWW IN MAC it is located at local hard-rive/user/sites ) and name it test, after that open your web-browser and write localhost/WWW/test.php then you would see php programming as result.

Installing PHP on Mac OSX

To install php on mac osx fallow the fallowing steps

  • download all in one pack from mamp .
  • install it in to mac set the  web browser and server to localhost.
  • restart the Computer.
  • after restarting start the mamp server when mamp server is started click on start to strat all the services that is provided with mamp.
  • open your mac web browser and type local host to check every thing is working properly.

Installing PHP on Windows

To run php on the computer we need to install php to download php visit the website here

download it and install php on to your machine the next thing is to set up a server, to set up a server we need to download it visit the website and download apache here 

Install it in to your computer and set the server to localhost. restart your computer after restarting start the Apache web server and php. to check that every thing is working properly open you web-browser and type localhost at the search bar if  ti open a web page which give you info about php that means everything is working,There  is also an easy way to install php and Apache and also mysql in one pack this pack is called wamp server to download it visit this website here

Download it and install it into your windows machine after that restart your computer after restarting start the wamp server you will see a menuu tray icon click on it  and then click on start all services after that click on localhost then your web browser will popup remember that choose the web browser in the installing process and also  remember to set the server to localhost.

if you did every thing properly then it would show the information about wamp server.

What is php ?

PHP is a server side scripting language to make dynamic websites pages and it is one of the firs server side scripting language to be imbedded  in HTML code PHP is installed on more than 20 million Web sites and 1 million Web order run php on the computer or server the user needs to Download and install php into there machine, php is complied in to HTML code so the web-browser can understand.php stand for Hypertext Preprocessor, php use html tags and the syntax of this language is very smiler to java script and action-script.the following code is written in php.

<title>PHP programming</title>
<?php echo “PHP Programming”;  ?>

note that php always start with a php tag (<?php?>), the php code stop at the end of the tag.