Blog Introductions
In this blog contains tutorials about HTML Tutorials, Python Tutorials, CSS Tutorials, How to, PHP Tutorials, Java Tutorials, C++ Tutorials, Tutorials, Examples, Source code,Learning,
Tips and Software development services. Php Variables and its types | Php tutorials Bestitworriors
Php Variables and its types
Php Variables and its types | Php tutorials Bestitworriors - Variables are the containers for storing data and information in itself that have different type of informations in it.Variables hold information and data but for temporary or for specific purpose.It hold information untill work done on information and data.Php support many types of variable like integer , float , string ,character etc
Some Key Points for Php variables
- Start with dollor ($name) sign
- Variables Must not start with numbers
- Php Variables have local and globle scope
- Local scope variables are declear inside of function and can't be access by outside of functions
- Globle Scope variables declear outside of function globally but can't access inside of function
- Php support almost all types
Code
< ?php
// Use
Dollar
sign($) to
initilize
the
variables
$name = "Bestitworrior";
$value1 = 10;
$value2 = 10.3;
// Show
Variables
echo
"I love this channel name is $name";
echo
"<br>"
echo
"I love this channel name is ".$name;
echo
"<br>";
echo $value1;
echo
"<br>";
echo $value2;
function
fun()
{
$value3 = 10;
// Show
Error
Can
't access globel variable
echo $value1;
echo $value3;
}
// Show
Error
Can
't access Local variable outside Functon
echo $value3;
? >
OutPut
I love this channel name is Bestitworrior
I love this channel name is Bestitworrior
10
10.3
Notice: Undefined variable: value1
10
Notice: Undefined variable: value3
I love this channel name is Bestitworrior
10
10.3
Notice: Undefined variable: value1
10
Notice: Undefined variable: value3
0 Comments