Is PHP a loosely typed language?

author details
AdiPie
8th Jan 2021
2 mins read
Image
Is PHP a loosely typed language

PHP is a loosely typed language because it does not require any defining the variable. while announcing a variable in these programming scripts, there is no need of characterizing or ordering the information type stored in them. While working with these programming scripts, you can create another variable, to be specific $string and provide the value as intiger.

Few samples that will show you the clearity:

In the case of C, you assign an integer as:
int c = 1; // assignment is not compulsory

In PHP:
$PHP = 1; // assignment desccribe the type of variable

In comparison to strict type language, you cannot define a different kind of value in a different kind of variable e.g. int will only have int value, you cannot put a string in that.

But in the case of PHP, you will change the type of variable anytime like for ex:

$PHP = 1; // become int
$PHP = “Congrats Now I am a String”;