PHP Variables | Variables in PHP language - PHP Tutorial 18
2.4 هزار بار بازدید -
5 سال پیش
-
Notes for You:: PHP Variables.-
Notes for You:: PHP Variables.
- Variable is a named memory location, whose value may change during the execution of a program.
- While building any web application (ex. banking, game etc.) we come across variety of data and data values.
- According to the requirement of the application we should be able to store and process them.
- To store and process data and data values we should be able to grab computer memory locations and access them within a script.
- To grab a chunk of memory and access it within the script, we need to declare a variable or a constant.
Declaring a variable or a constant:
- means allocating a memory location for some data
Initializing a variable or a constant:
- means putting an initial data value within that allocated memory location
- In order to change the value in a variable or constant, we need to assign a new value to it.
Assigning a variable or a constant:
- means putting a new data value within that allocated memory location
Syntax:
// declaration and initialization of a variable
$nameOfVariable=initial value;
// assigning new value to a variable
$nameOfVariable = new value;
Note:
- Variables must be initialized, before using them.
- Like in other langauges; No comma separated variable or constants allowed.
- While accessing a variable directly within a string, it’s recommended to enclose a variable within {}
Example Code:
<?php
$playerName = "Manjunath";
echo $playerName,"<br/>";
$playerScore = 0;
echo $playerScore,"<br/>";
$playerScore=20;
echo $playerScore,"<br/>";
echo "<br/>";
echo "Player name= ",$playerName,"<br/>";
echo "Player score= ",$playerScore,"<br/>";
$isGameOver; // you can declare
$isGameOver = true; // but must initialize
echo $isGameOver,"<br/>"; // to use it
echo "<br/>";
$a,$b; // error
echo "Player name= $playerName","<br/>";
echo "Player name= {$playerName}","<br/>";
?>
Note:
- replace < with less-than symbol.
- replace > with greater-than symbol.
=========================================
Follow the link for next video:
PHP Tutorial 19 - Constants in PHP language | PHP Constants Tutorial
PHP Constants | Constants in PHP lang...
Follow the link for previous video:
PHP Tutorial 17 - PHP Identifiers | PHP Naming Conventions
PHP Identifiers | Identifiers in PHP ...
=========================================
PHP Tutorials Playlist:-
PHP Tutorials
=========================================
Watch My Other Useful Tutorials:-
MySQL Tutorials Playlist:-
MySQL Tutorials
HTML Tutorials Playlist:-
HTML Tutorials
CSS Tutorials Playlist:-
CSS Tutorials
JavaScript Tutorials Playlist:-
JavaScript Tutorials
=========================================
► Subscribe to our YouTube channel:
chidrestechtutorials
► Visit our Website:
https://www.chidrestechtutorials.com
=========================================
Hash Tags:-
#ChidresTechTutorials #PHP #PHPTutorial
- Variable is a named memory location, whose value may change during the execution of a program.
- While building any web application (ex. banking, game etc.) we come across variety of data and data values.
- According to the requirement of the application we should be able to store and process them.
- To store and process data and data values we should be able to grab computer memory locations and access them within a script.
- To grab a chunk of memory and access it within the script, we need to declare a variable or a constant.
Declaring a variable or a constant:
- means allocating a memory location for some data
Initializing a variable or a constant:
- means putting an initial data value within that allocated memory location
- In order to change the value in a variable or constant, we need to assign a new value to it.
Assigning a variable or a constant:
- means putting a new data value within that allocated memory location
Syntax:
// declaration and initialization of a variable
$nameOfVariable=initial value;
// assigning new value to a variable
$nameOfVariable = new value;
Note:
- Variables must be initialized, before using them.
- Like in other langauges; No comma separated variable or constants allowed.
- While accessing a variable directly within a string, it’s recommended to enclose a variable within {}
Example Code:
<?php
$playerName = "Manjunath";
echo $playerName,"<br/>";
$playerScore = 0;
echo $playerScore,"<br/>";
$playerScore=20;
echo $playerScore,"<br/>";
echo "<br/>";
echo "Player name= ",$playerName,"<br/>";
echo "Player score= ",$playerScore,"<br/>";
$isGameOver; // you can declare
$isGameOver = true; // but must initialize
echo $isGameOver,"<br/>"; // to use it
echo "<br/>";
$a,$b; // error
echo "Player name= $playerName","<br/>";
echo "Player name= {$playerName}","<br/>";
?>
Note:
- replace < with less-than symbol.
- replace > with greater-than symbol.
=========================================
Follow the link for next video:
PHP Tutorial 19 - Constants in PHP language | PHP Constants Tutorial
PHP Constants | Constants in PHP lang...
Follow the link for previous video:
PHP Tutorial 17 - PHP Identifiers | PHP Naming Conventions
PHP Identifiers | Identifiers in PHP ...
=========================================
PHP Tutorials Playlist:-
PHP Tutorials
=========================================
Watch My Other Useful Tutorials:-
MySQL Tutorials Playlist:-
MySQL Tutorials
HTML Tutorials Playlist:-
HTML Tutorials
CSS Tutorials Playlist:-
CSS Tutorials
JavaScript Tutorials Playlist:-
JavaScript Tutorials
=========================================
► Subscribe to our YouTube channel:
chidrestechtutorials
► Visit our Website:
https://www.chidrestechtutorials.com
=========================================
Hash Tags:-
#ChidresTechTutorials #PHP #PHPTutorial
5 سال پیش
در تاریخ 1398/05/25 منتشر شده
است.
2,437
بـار بازدید شده