PHP MYSQL -Variables, Data Types - 4

 PHP Variables

PHP Variables are "containers" for storing information.

A variable can have a short name (like m and n) or a more descriptive name (age, carname, total_volume).


Rules for PHP variables:

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

PHP Data Types

    Variables can store data of different types, and different data types can do different things.

PHP supports the following data types:

  • String
  • Integer
  • Float (floating point numbers - also called double)
  • Boolean
  • Array
  • Object
  • NULL
  • Resource
Ex1 :
<?php
$str = "Vesrn";
echo $str;
?>

Ex2
<?php
$str1 = "Vesrn";
$str2 = "Technologies";
echo $str1.$str2;
?>

Ex3:
<?php
$x = 10;
$y = 20;
echo $x+$y;
?>


Ex4:
<?php
$rank = 1;
echo "Vesrn Technologies is always in $rank";

?>


Video

Popular posts from this blog

Install Windows 7 Operating System - Practical

COPA Bits for Computer Based Test (CBT) by Venugopal Vanjarapu

COPA