Concept

How do you assign values to variables in PHP?

ComputerScienceOne / Using Variables

"To use a variable in PHP, you simply need to assign a value to a named variable identifier and the variable is in scope. Variable names always begin with a single dollar sign, $ . The assignment operator is a single equal sign, = and is a right-to-left assignment. The variable that we wish to assign the value to appears on the left-hand-side while the value (literal, variable or expression) is on the right-hand-size. For example:\n\n1 $numUnits = 42;\n\n2 $costPerUnit = 32.79;\n\n3 $firstInitial = \"C\";\n\nEach assignment also implicitly changes the variable’s type. Each of the variables above becomes an integer, floating point number, and string respectively. Assignment statements are terminated by a semicolon like most executable statements in PHP. The identifier rules are fairly standard: a variable’s name can consist of lowercase and uppercase alphabetic characters, numbers, and underscores. You can also use the extended ASCII character set in variable names but it is not recommended (umlauts and other diacritics can easily be confused). Variable names are case sensitive . As previously mentioned, variable names must always begin with a dollar sign, $ . Stylistically, we adopt the modern lower camel casing naming convention for variables in our code."

Related Ideas

How do you assign values to variables in PHP? | ComputerScienceOne | Bifalgorithm | Bifalgorithm