Monday, March 4, 2024

PHP data Type

 Variable Data Type in PHP

PHP data type


1] PHP String :-

        Represents a sequence of characters.

Example: $name = "seeta";

2] PHP Integer :-

Represents whole numbers without decimal points.

Example :- $number = 100;

3] PHP Float :-

Floating point numbers or Doubles

Represents numbers with decimal points.

Example :- $float_number = 9.7;

4] PHP Boolean :-

Represents true or false values.

Example: true;

5] PHP Array :-

Represents a collection of elements, each identified by a key.

Example: $colors = array("red", "green", "blue");

6] PHP Object :-

Represents instances of user-defined classes.

Example:

class Car { public $color = "blue"; public $make = "Toyota"; } $car = new Car();

7] PHP NULL :-
Represents a variable with no value.
Example: $variable = null;
  1. 8] PHP Resource :-
  2. Represents a special variable that holds a reference to an external resource.
  3.    A common example of using the resource data type is a database call.                         It is the storing of a reference to functions and resources external to PHP.

  4. Variable data type
    Example

    /* data type  variable */
    <?php
    $no1=10;
    $no2=85.99;
    $name1='aman';
    $name2="aishwarya";
    $status="false";
    $student=array("payal","aishwary");

    VAR_DUMP($no1);
    var_dump($no2);
    var_dump($name1);
    var_dump($name2);
    var_dump($status);
    var_dump($student);
    ?>


    variable data type
    Output

    variable data type/output


    READ MORE

No comments:

Post a Comment