The type of a variable is decided at runtime by PHP depending on the context in which that variable is used
- Basic types of data in PHP
- String : text or information treated as text (numbers within quotes)
- Integer : whole numbers
- Float : decimal numbers
- Boolean : (or Bool) : True or False
- Compound types:
- Object
- Array
- Special types:
- NULL
- Resources
Important Notes:
- If you want to check out the type and value of certain expression, use var_dump().
- Mention that other languages are strongly typed
- String - text or anything in single or double quotes including numbers or numbers with leading zeros such as 007
- Integer - whole numbers
- Float - decimal numbers
- Bool - True/False, or 0/1
- An array in PHP is actually an ordered map. A map is a type that maps values to keys. this type is optimized in several ways, so you can use it as a real array, or a list (vector), hashtable (which is an implementation of a map), dictionary, collection, stack, queue and probably more. Because you can have another PHP array as a value, you can also quite easily simulate trees.
- A resource is a special variable, holding a reference to an external resource.
- The special NULL value represents that a variable has no value. NULL is the only possible value of type NULL.
- Object - instance of a class
Amazing ����
ReplyDeletethanks man
ReplyDelete