PHP Tutorial Part-2 || PHP Variables

in Hindwhale Community2 days 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

Coin Marketplace

STEEM 0.18
TRX 0.15
JST 0.028
BTC 63006.79
ETH 2456.26
USDT 1.00
SBD 2.59