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

what are variables in php

silencement
Release: 2023-02-25 07:42:01
Original
3028 people have browsed it

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;
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template