63Chapter 5Syntax and VariablesThe (Cheapest web hosting) different capitalization schemes make
63Chapter 5Syntax and VariablesThe different capitalization schemes make for different variables. (Surprisingly, under thedefault settings for error reporting, code like this fragment will not produce a PHP error seethe section Unassigned variables, later in this chapter.) On the other hand, unlike in C, function names are notcase sensitive, and neither are thebasic language constructs (if, then, else, while, and the like). Statements are expressions terminated by semicolonsA statementin PHP is any expressionthat is followed by a semicolon (;). If expressions corre- spond to phrases, statements correspond to entire sentences, and the semicolon is the fullstop at the end. Any sequence of valid PHP statements that is enclosed by the PHP tags is avalid PHP program. Here is a typical statement in PHP, which in this case assigns a string ofcharacters to a variable called $greeting: $greeting = Welcome to PHP! ; The rest of this subsection is about how such statements are built from smaller componentsand how the PHP interpreter handles the evaluation of statements. (If you already feel com- fortable with statements and expressions, feel free to skip ahead.) Expressions are combinations of tokensThe smallest building blocks of PHP are the indivisible tokens, such as numbers (3.14159), strings ( two ), variables ($two), constants (TRUE), and the special words that make up thesyntax of PHP itself (if, else, and so forth). These are separated from each other by whites- pace and by other special characters such as parentheses and braces. The next most complex building block in PHP is the expression, which is any combination of tokens that has a value. A single number is an expression, as is a single variable. Simpleexpressions can also be combined to make more complicated expressions, usually either by putting an operatorin between (for example, 2+(2+2)), or by using them as input to afunction call (for example, pow(2*3,3*2)). Operators that take two inputs go in betweentheir inputs, whereas functions take their inputs in parentheses immediately after theirnames, with the inputs (known as arguments) separated by commas. Expressions are evaluatedWhenever the PHP interpreter encounters an expression in code, that expression is immedi- ately evaluated. This means that PHP calculates values for the smallest elements of theexpression and successively combines those values connected by operators or functions, until it has produced an entire value for the expression. For example, successive steps in animaginary evaluation process might look like: $result = 2 * 2 + 3 * 3 + 5; (= 4 + 3 * 3 + 5) //imaginary evaluation steps(= 4 + 9 + 5) (= 13 + 5) (= 18) with the result that the number 18 is stored in the variable $result. Precedence, associativity, and evaluation orderThere are two kinds of freedom PHP has in expression evaluation: how it groups or associatessubexpressions and the order in which it evaluates them. For example, in the evaluation pro- cess just shown, multiplications were associated more tightly than additions, which affectsthe end result.
From our experience, we can recommend PHP5 Web Hosting services, if you need affordable webhost to host and run your web application.