Home >Backend Development >PHP Problem >what are variables in php

what are variables in php

silencement
silencementOriginal
2019-09-26 16:43:533033browse

what are variables in php

Variables are containers for storing information

PHP variables

Just like algebra, PHP variables can be used to hold values ​​(x=5) and expressions ( z=x y).

Variable names can be short (such as x and y) or more descriptive (such as carname, total_volume).

PHP variable rules:

Variables start with the $ symbol, followed by the name of the variable

The variable name must start with a letter or an underscore

Variable name Cannot start with a number

Variable names can only contain alphanumeric characters and underscores (A-z, 0-9, and _)

Variable names are case-sensitive ($y and $Y are two Different variables)

Note: PHP variable names are case-sensitive!

The following example demonstrates how PHP creates variables

<?php
$txt="Hello world!";
$x=5;
$y=10.5;
?>

The above is the detailed content of what are variables in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn