Home >Backend Development >PHP Problem >What does php weakly typed variable mean?

What does php weakly typed variable mean?

王林
王林Original
2020-06-30 15:17:414715browse

php Weakly typed variables mean that when declaring a variable, we do not need to specify the data type it stores. PHP is a weakly typed language. It does not strictly check variable types. Variables can declare their types without explicitly declaring their types, but are directly assigned values ​​during runtime.

What does php weakly typed variable mean?

Weakly typed variables

PHP is a weakly typed, dynamic language script. When declaring a variable, you do not need to specify the data type it holds.

PHP does not strictly check variable types. Variables can declare their types without displaying them, and assign values ​​directly during runtime. Variables can also be converted freely.

As shown in the following example, without implementation declaration, $i can be assigned any type of value.

What does php weakly typed variable mean?

Example:

<?php  
$var = 1;  
$var = "variable";  
$var = 1.00;  
$var = array();  
$var = new Object();

Dynamic variables can be changed during runtime, and there is no need to declare the variable type before use.

If you want to learn more related knowledge, please visit php Chinese website.

The above is the detailed content of What does php weakly typed variable mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn