What type of language is php?

(*-*)浩
Release: 2023-02-25 14:20:02
Original
4162 people have browsed it

PHP is a weakly typed language

What type of language is php?

##We noticed that there is no need to ask PHP Declare the data type of the variable.

PHP will automatically convert the variable to the correct data type based on its value. (Recommended learning: PHP video tutorial)

In a strongly typed programming language, we must declare (define) the type and name of the variable before using it.

Weakly typed languages ​​are also called weakly typed definition languages. The opposite of strongly typed definitions. Languages ​​such as VB and PHP are weakly typed languages.

A weakly typed language is a language with weakly typed definitions. A certain variable has a defined type, and the variable can be automatically converted according to changes in the environment without explicit forced conversion.

For example: In vbscript, you can concatenate the string 12 and the integer 3 to get the string 123, and then treat it as the integer 123 without explicit conversion.

Weak typing sometimes seems very convenient, but sometimes it is extremely error-prone. For example:

var result=5+5; //two numbers
alert(result);  //outputs "10"
var result=5+'5'; // a number and a string
alert(result);  //outputs "55"
Copy after login

Therefore, when using weakly typed languages, you must also pay special attention to the data type to prevent errors

Whether it is a strongly typed language or a weakly typed language, the fundamental judgment is whether it will Implicit language type conversion. Strongly typed languages ​​are slightly slower than weakly typed languages, but the rigor brought by strongly typed definition languages ​​can avoid unnecessary errors.

The above is the detailed content of What type of language is php?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!