php-variable (1)

Source: Internet
Author: User

Variables in PHP

Variables are used to store values, such as numbers, text strings, or arrays.

Once a variable is set, we can use it repeatedly in the script.

In PHP, you do not need to declare a variable before you set it.

All variables in PHP start with the $ symbol.

For example:

$myValue = 1;

In PHP, variable names and variable values are stored in different memory spaces, and a variable value can be represented by several different variable names.

Variable values can also be used as variable names.

For example:

<? PHP $myValue = ' abc '; $myOutput = ' myvalue '; Echo $$myOutput;? >

The results shown are:

Abc

The resulting floating-point result in PHP is not equal to the result of a floating-point variable, because the result of the operation is an approximate (imprecise)

For example:

<?PHP$a= 0.9;$b= 0.3;$c= 0.6;if(($a-$b)==$c)Echo $a,‘-‘,$b, "equals",$c;ElseIf(($a-$b)!=$c)Echo $a,‘-‘,$b, "Not equal to",$c;?>

The result is:

0.9-0.3 Not equal to 0.6

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.