PHP is a popularly used open source scripting language for website development. It is an acronym for Hypertext Pre-Processing derived from its previous version known as Personal Home Page Tools.
Programming languages like Python, Java, C+, etc. are executed on your own computer but PHP is executed on a web server, a web space, and the final output is sent to your browser. A software called Wampserver is used in action to save the high cost of web hosting required to test codes on PC. It is compatible and works perfectly in every type of web browsers.
Some influential names in world wide web like Facebook and CMS (Content Management System) like WordPress are built in PHP. So, learning to code in PHP has become crucial for a good web developer.
You can accomplish the following tasks with the help of PHP:
- Create a forum
- Develop login pages for users
- Gather user information, cookies and data from a form
- Display plain HTML, CSS, images, PDF, surveys, etc.
The best part of PHP is that it is made for absolute beginners. We don’t need any programming experience to code in PHP. However, having some extra knowledge in HTML and CSS is considered useful.
- Basics of XML Language for absolute beginners
- The most important 23 terms related to python programming.
How to assign variables in php?
Variables are like storage devices in your PHP program to collect values.
Example: Let us consider that, you have a dumbbell and two gloves. Unfortunately, your hands are full and you don’t have enough storage left with you. So you decided to take help from two persons named Chad and Peter to carry those items from shopping mall to the car. Chad has the dumbells and Peter have the gloves. Because you have a weak memory, you decided to give those people a name and noted down in a piece of paper as given below:
In above example, chad_dumbells and peter_value are two variables that store a value each. Let us consider the number of dumbells is 2 and number of gloves is 4. Then we can write it in PHP as follows:
- $chad_dumbells = 2;
- $peter_gloves = 4;
Rules to follow while assigning variables
Please note that the variables always start with a dollar sign ‘$’ and end with a semicolon ‘;’. They start with lower cased letters or alphabets and they are case sensitive. You cannot use any numbers at the start of a variable but numbers can be used later. The equals to ‘=’ sign are called the operator and it is used to assign a value to a variable.
At the end:
This is not the end. You just learnt how to get started with PHP and assign variables to it. I hope you get some idea with the help of this guide. In my forthcoming article, I will share some more information about variables and new syntax on PHP. [cu]