php我以为是弱类型编程语言,但还是有数据类型的,而且越来越强调类型了。
very single expression in PHP has one of the following built-in types depending on its value:
PHP is a dynamically typed language, which means that by default there is no need to specify the type of a variable, as this will be determined at runtime. However, it is possible to statically type some aspect of the language via the use of type declarations. Different types that are supported by PHP's type system can be found at the type system page.
Types restrict the kind of operations that can be performed on them. However, if an expression/variable is used in an operation which its type does not support, PHP will attempt to type juggle the value into a type that supports the operation. This process depends on the context in which the value is used. For more information, see the section on Type Juggling.
Atomic types¶
Some atomic types are built-in types which are tightly integrated with the language and cannot be reproduced with user defined types.
The list of base types is:
- Built-in types
- User-defined types (generally referred to as class-types)
- callable type