PHP Tutorial Part-2 || PHP Variables

in hive-179660 •  5 months ago 

Dark Blue Gradient Travel Banner Landscape (1).png

Photo Make with canva

In today's scene of PHP our point is: PHP Variables

Creating (Announcing) PHP Variables

In PHP, a variable begins with the $ sign, taken after by the title of the variable:

A variable can have a brief title (like $x and $y) or a more expressive title ($age, $carname, $total_volume).

  • A variable begins with the $ sign, taken after by the title of the variable
  • A variable title must begin with a letter or the emphasize character
  • A variable title cannot begin with a number
  • A variable title can as it were contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
    Variable names are case-sensitive ($age and $AGE are two diverse variables)
    Example:

PHP is a Freely Written Language

In the illustration over, take note that we did not have to tell PHP which information sort the variable is.

PHP consequently partners a information sort to the variable, depending on its esteem. Since the information sorts are not set in a strict sense, you can do things like including a string to an numbers without causing an error.

In PHP 7, sort announcements were included. This gives an choice to indicate the information sort anticipated when announcing a work, and by empowering the strict prerequisite, it will toss a "Lethal Mistake" on a sort mismatch.

You will learn more around strict and non-strict prerequisites, and information sort statements in the PHP Capacities chapter.

Variable Types

PHP has no command for pronouncing a variable, and the information sort depends on the esteem of the variable.

PHP bolsters the taking after information types:

  • String
  • Integer
  • Float (drifting point numbers - moreover called double)
  • Boolean
  • Array
  • Object
  • NULL
  • Resource

Get the Type

To get the information sort of a variable, utilize the var_dump() function.

Assign Different Values
You can relegate the same esteem to numerous factors in one line:

Please watch the first episode of this episode Link Here

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  
Loading...