$variables ( chap 1 PHP )

 Variables are "containers" for storing information
Many of the beginners thinks that if $x = 1 (variable x = 1 ) that means $x is equal to 1 but that's not right.Here x is like a container which contains the number 1.



You might think that it is the same thing but its not, there is an " === " operator which will compare and tell if the variables are exactly same.And by exactly same it must be exactly same,like $var1="hello" and $var2="Hello" ,here both are hello but they are not the same,right now this might not be something of your interest but it'll be a big fact,worth looking into while we learn more.

So 

Creating /Declaring PHP Variables

In PHP, a variable starts with the $ sign, followed by the name of the variable:
<?php
$txt = "Hello world!";
$x = 5;
$y = 10.5;?>



A variable can have a short name (like x and y or xy or yx) or a more descriptive name (age, carname, total_volume)

  • A variable name cannot start with a number
  • Variable names are case-sensitive ($age and $AGE are two different variables)
  • A variable starts with the $ sign, followed by the name of the variable
  • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
A variable name must start with a letter or the underscore character 


remember PHP variables are case sensitive.
so $var_X is not as the same as $var_x 


Output Variables

<?php
$txt = "PHP";
echo "$txt is fun ";
?>
or

 <?php
$txt = "coding";
echo "I love $txt!";
?>
The following example will produce the same output as the example above:

<?php
$txt = "W3Schools.com";
echo "I love " . $txt . "!";
?> 



Now for a simple math,

<?php
$x = 5;
$y = 4;
echo $x + $y;
?>


Setting Up For C

Helllooo there,
Today we are going to get set for C
The mother of All Language :D

For C,We need a compiler.you can use any compiler as you wish.totally your choice.I'll use Code Blocks . You can download it from here.
after downloading it,install it.
Now i'll show you how to compile C

you file needs to has the extension ".c" ( dot c )

now on the top left of code blocks there is "file"
click on it,then new>empty file

now type/copy paste the following code :


                                                  #include <stdio.h>


                                                    main ()
                                                   {
                                                   printf("Hello World");


                                                     }

its a simple C code for printing Hello World

then you have to build it
you can choose either build button or build and run button.
then compile it


if you have the output as that one,well you have compiled your first C program and we are ready for next lessons.

If you make any mistakes the error would show up in this box

:)


Setting Up For PHP

All right,so set up the things we need to install for practicing php. 
we need Apache and Mysql running so i'm going to use XAMPP.you can download it from here.
download and install.By default it should be installed in C:\xampp ( if you are running windows)after installation start up the xampp server.

and start Apache and MySQL 







So open up xampp folder and you'll find some files and folders. one of the is "htdocs".open up the folder,now,which php file we wanna run should be on that folder,you have to have that php file in that folder.and we also need the Apache n MySQL up n running.
so now lets test it


so write a php file,you can use this one :


<?php
$var="Hello World";
echo $var;

?>


no save it into C:\xampp\htdocs\var.php

(you can use any name as you like,make sure to use the .php  extension)
no go to your browser,in the address bar type localhost/var.php

and you there you go:





if you have this output then you're all set to go (Y)