Define Variable In PHP
A variable is a means of storing a value, such as text string “Hello World!” or the integer value 4. A variable can then be reused throughout your code, instead of having to type out the actual value over and over again. In PHP you define a variable with the following form:
$variable_name = Value;
If you forget that dollar sign at the beginning, it will not work. This is a common mistake for new PHP programmers!
Also, variable names are case-sensitive, so use the exact same capitalization when using a variable. The variables $a_number and $A_number are different variables in PHP’s eyes.
Here is how we define a variable in PHP.
// $name is a variable which stores value of javed
// display value of variable
- Simple PHP Script – Lets Start PHP – Echo Hello PHP If you want to learn PHP you have come to the right place. I will not only teach you how […]
- Data Types In PHP Data types are many e.g. Boolean, Integer, Double (or float), String and there might be […]
- PHP ForEach Loop PHP provides an easy way to use every element of an array with the For each statement. […]
- PHP Strings Before you can use a string you have to create it! A string can be used directly in a […]
- PHP Echo in PHP PHP function echo is a means of outputting text to the web browser. Here is how we can […]
- Action At Link Using PHP Use this example to show some hidden message at page using PHP. You can use two pages […]
- PHP Switch Statement Examples With the use of the switch statement you can check for many conditions at once, and the […]
- PHP Post And Get Post and Get are both used in forms to pass data from one page to another but there is a […]
- PHP While Loop The while keyword takes a condition in parentheses, and the code block that follows is […]
- PHP Increment Operator Some of the most frequently used code in PHP or any programming language is the code […]