In a loosely typed language, we are NOT required to define the type of a variable while declaring it.
For example, Perl and PHP. They both are a loosely typed languages. We can declare a variable without specifying the type of a variable. A loosely typed language automatically associates a data type to the variable, depending on the value of a variable.
For example, take a look at the following variable declarations. In the first line we have declared a variable named $var1, which can be used as an integer or string later on.
var $var1; $var1 = 1; #var1 variable is now integer. $var1 = "hello"; #var1 variable is now a string.
Strongly typed language is the opposite of a loosely typed language for example C.
Any programming language which requires a variable type to be defined is a strongly typed language. For example, programming language C is a strongly typed language as you must specify the type of the variable when declaring it.
Let's take a look at the example below. We are declaring the same variable var1 as an integer in the first line but in the second line we have to change the type to a floating point in order to change the value and same in the third line we are changing the type to char to assign a character value.
int var1 = 25; float var1 = 2.3; char var1 = 'e';
difference Loosely Typed Language Strongly Typed Language