Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Scalar types in php

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 39
    Comment on it

    Welcome to Findnerd. Today we are going to dicuss the strict typing mode and weak typing mode which is introduced in PHP7. strict typing mode is not activated by default. You need to activate it via declare like this


    It should be first statement in your file. It will activate the strict typing mode in current file. It will only applied called functions in the file not defined functions.

    function userdata(string $name,int $phone){
    echo 'name:' . $name . '<br />' . $phone . '<br />';

    In above example we have set the strict typing mode. We created a function named userdata with two arguments that are name , datatype is string and another is integer phone we called the function twice. In second call we passed the phone number as string. It should be integer. It will return the error for correct type.

    If you do not declare the strict type to 1, it will be work as strict typing mode. In weak typing it will convert the phone number into a interger. You can also set the weak typing by this


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: