Your SlideShare is downloading. ×
Php variables
Php variables
Php variables
Php variables
Php variables
Php variables
Php variables
Php variables
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Php variables

220

Published on

This presentation shows fundamentals of PHP …

This presentation shows fundamentals of PHP
Variables - declaring variables, Variable scope
Static Variable and Reserved words.

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
220
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. PHP Variables
  • 2. TOC
    • Declaring variables
    • Variable scope
    • Static Variable
    • Reserved words
  • 3. What is a variable
    • Stores value
    • myName is “Joe” is $myName = “Joe”; //strings
    • UserId is 086AFTG is $UserId = 086AFTG; // numbers
  • 4. Rules of PHP Variable naming
    • starts with a letter (A-Z, a-z) or underscore (_), followed by any number of letters, numbers, or underscores.
    • variable name is case-sensitive. So $MyName and $MYNAME are not same.
    • You don’t need to mention what kind of value you are going to store.
  • 5. Variable Scopes
    • Local Scope
    • function myFunction () {
    • $FirstName = “Joe”; // local
    • //do something }
    • Global Scope
    • $department = “Marketing”; // global
    • function myFunction () {
    • $FirstName = “w3resource”; 
    • //do something }
  • 6. Static Variables
    • function test_count()
    • {
    • static $x=1;
    • echo $x;
    • $x++;
    • }
    • test_count(); test_count(); test_count();
    • //Displays 123
  • 7. Reserved Words
    • Cannot be used as constants, class names, function or method names.
    • May be used as variable names, but confusing so avoidable.
    • Examples: case, namespace, __METHOD__ etc.
  • 8. Further Reading
    • W3resource PHP Variables Tutorial
    • PHP :  Variables  -  Manual

×