Variables in php
Creating/Declaring a variable is very simple in PHP.
A variable in php starts with the "$" sign, followed by the name of the variable.
In PHP, you don't have to mention the datatype of the variable when you declare it. You dont have to declare the variable first and then use it. The variable is created when you assign a value to it.
In the above example, $message will have the value "How are you?" , $a will be assigned with the value "5" and $b will be having the value "2".
REMEMBER: When assigning a string to any variable, put it inside the double quotes.
Any value/message typed in double quotes(" ") will be display the string as it as.
Here $message will have the value "How are you?", $a will have the value as "2" and $b will have the value "10-8". By this we understand anything written inside the double quotes is a string or a message.
Concatenation of variables
In PHP, We can concatenate two or more variables using the dot "."
The output for the above code will look something like this:
5 is the number and How are you? is the string
1.A variable name can be any aplha-numeric combination but it should always start with a alphabet.
2.We cannot use any special characters/symbol except underscore(_) while naming a variable.
3.Keywords cannot be used as variables.
Keywords are those reserved words which have predefined meaning.
For example: array, empty, final are few keywords in php.
Latest PostsCreate dynamic SQL insert query in php and mysql How to Export MySQL data to excel sheet in PHP How to import excel file into mysql database in PHP How to make Registration / Signup form in php How to upload an image in PHP mysql How to make Login System with Session in PHP MySQL How to Delete data from database in php mysql How to Update Data in MySQL Database in PHP How to Fetch/Retrieve data from database in php mysql How to Insert data into database in php mysql
© Copyright - 2018 - 2022 | All rights reserved at Funda of Web IT