php variable

A variable is a means of storing a value, such as text string “Hello World!” or the integer value 4. A variable can then be reused throughout your code, instead of having to type out the actual value over and over again. This is the tutorial to guide you how to create and use PHP variable.

Syntax:

Example:

Note: Variable names are case-sensitive, so use the exact same capitalization when using a variable. The variables $DCS_number and $dcs_number are different variables in PHP’s eyes.

php variable naming conventions

There are a few rules that you need to follow when choosing a name for your PHP variables.

  • PHP variables must start with a letter or underscore “_”.
  • PHP variables may only be comprised of alpha-numeric characters and underscores. a-z, A-Z, 0-9, or _ .
  • Variables with more than one word should be separated with underscores.

  • Variables with more than one word can also be distinguished with capitalization.

This tutorial guides on how to use php variable. But if you have any question, raise it at Forum Section.