How to make variable in php - Tutorial this time that i will discuss about how to make variable in php. Before I give examples of tutorials to create programs using variables, first let me explain a bit about what is a variable, what is the function of the variable and what kind of variable is allowed in the php programming language. Here's an explanation.
• Used to store a value, data or information.
• Variable name begins with $ sign.
• Unlimited length.
• After the $ sign starts with a letter or under-scrore (_). Character.
• The next can consist of letters, numbers, and certain characters.
• Allowed (ASCII characters from 127 - 255).
• Case-sensitive.
• No need to be declared.
• Must not contain spaces.
• Example:
True
- $_name
- $first_name
- $name3
- $name_3
False
- $3name
- $name?
- $first+name
- $first.name
- $first name
Next examples of programs using variables
File Name: variable.php
Description: Program fills and displays variables.
Type the following php command code into notepad
<?php
$number = "0411500400";
$name = 'Johans Supri';
echo "Number : " . $number . "<br>";
echo "Name : $name";
?>
After that save with variable.php name
To see the result open the browser and type http://localhost/variable.php in the address bar. Then the result will look like the following
That's the tutorial I can give you about how to make variable in php, hopefully it can be useful for you. See also tutorial on: How to Say Hello in PHP.
• Used to store a value, data or information.
• Variable name begins with $ sign.
• Unlimited length.
• After the $ sign starts with a letter or under-scrore (_). Character.
• The next can consist of letters, numbers, and certain characters.
• Allowed (ASCII characters from 127 - 255).
• Case-sensitive.
• No need to be declared.
• Must not contain spaces.
• Example:
True
- $_name
- $first_name
- $name3
- $name_3
False
- $3name
- $name?
- $first+name
- $first.name
- $first name
Next examples of programs using variables
File Name: variable.php
Description: Program fills and displays variables.
Type the following php command code into notepad
<?php
$number = "0411500400";
$name = 'Johans Supri';
echo "Number : " . $number . "<br>";
echo "Name : $name";
?>
After that save with variable.php name
To see the result open the browser and type http://localhost/variable.php in the address bar. Then the result will look like the following
![]() |
Program View |
That's the tutorial I can give you about how to make variable in php, hopefully it can be useful for you. See also tutorial on: How to Say Hello in PHP.
Comments
Post a Comment