Hello guys, thank you for returning to my post, I have put an extra work to make sure my post is well understandable to my lovely readers who wish to learn php programming languages. And in this post we will discuss a very important aspect of most Programming languages which is 'Data Types and variables in PHP programming'. In my last post we discussed about the differences between Procedural programming and object oriented programming. If you have not read that you can read that here or you continue reading.
So before we dive in let's list out the points we will discuss today.
- What are Data types in php
- Different Data types in php
- What are Variables
- Rules in writing PHP Variables
What are Data types in PHP
Data types in programming are used most of the time when writing codes. It is something you can't do without in php programming, because PHP is sort of input, storing and displaying data to the viewers (client side) and there are lots if data in PHP programming but all are classified into four (4) different types.
Different Data types in PHP programming language
We have over 10 primitive data types in PHP. But all this 10 has been classified under four categories, which are the Scalar data types, Compound data type, Special data type and Pseudo-Type.S
ScalarData type
These includes: Strings, Integer, Float, Boolean
Compound Data type
These includes: Array, Object, Callable, Iterable
Special Data type
These includes: Resource, Null
For the purpose of this post we will be focusing on the scalar data type.
Scalar Data Types
What is Variable
Rules in writing Variables
- The '$' character is used to declare a variable in php
- The variable name must begin with a letter of an alphabet or an underscore (e.g $variable or $_variable)
- A variable name can only contain a-z, A-Z , 0-9 or _ (underscore)
- Spaces are not allowed in PHP variable. Where your variable name has more than one word, you can separate it with an _ (underscore) or you capitalize the first letter from the second word (e.g $variable_name or $variableName)
- Variable names in PHP are case sensitive.
1 Comments
Well understandable
ReplyDeletePost a Comment