-->

  • PHP numbers with numerical strings


    PHP numbers with numerical strings




    PHP Numbers

    You must have noticed one thing that whenever we take the numbers in the identification, then its conversion becomes automatic Or we can say that whatever number we give through Varible, the data type of the number is automatically correct according to its data type.Then, if you assign a string to the same variable, the type will change to a string. PHP numbers with integers

    This automatic conversion can sometimes break your code.


    PHP Numerical Strings


    The PHP is_numeric() function can be used to find whether a variable is numeric. The function returns true if the variable is a number or a numeric string, false otherwise.

    Example


    Check if the variable is numeric:



    Example 

    <html>

    </head>
    <body>


    <?php

    // Check if the variable is numeric   

    $x = 5985;
    var_dump(is_numeric($x));


    echo "<br>";


    $y = "5985";
    var_dump(is_numeric($y));


    echo "<br>";


    $z = "59.85" + 100;
    var_dump(is_numeric($z));


    echo "<br>";


    $xx = "Hello";
    var_dump(is_numeric($xx));

    ?>


    </body>
    </html>





    bool(true)
    bool(true)
    bool(true)
    bool(false)



    NOTE :- Video on This Topic :- Soon





    Have a Nice Stay Here : - )











  • 0 comments:

    Post a Comment

    For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.