Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    PHP Data Types

    In PHP, a variable's data type is not determined by the developer. At the time of interpretation of the web page, PHP decides the data type of variables.

    Data Types available in PHP:
    • Numeric
    • String
    • Boolean
    • Array
    • object
    • Resource
    • NULL

    Numeric Data Type

    There are two different numeric data types, which are used for number:

    • Integer
    • Double (floating point numbers)

    Integer Data Type

    Integer data type has full number values.

    Example:

    <?php
    $intValue = 100;
    ?>

    Double Data Type

    Floating point numbers are the contains Double.

    Example:

    <?php
    $doubValue = 55.5;
    ?>

    String Data Type

    String data type contains letters or textual information. Value is assigned to the double or single quotes.

    Example:

    <?php
        $strName = "Neel";
        $strId = "Neel456";
    ?>

    Converting Between Data Types

    Example:

    <?php
        $a = 9.88;
        echo (int) $a; // Outputs 9
    ?>

    Values cannot be converted to certain types; for example, you cannot convert any value into a resource. However, you can convert a resource into a numerical or string data type, in which case PHP will return the numeric ID of the resource, or the string Resource id # followed by the resource ID.



    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.