The difference between C and PHP syntax: the difference between C and PHP syntax
Maybe yes, published on
PHP syntax rules are very similar to C syntax rules. many internal functions in PHP call native C functions. Because the two languages run differently, there are also some differences in syntax in some cases. below are several examples.
Different ways to obtain global variables
Obtain the global variable value in the scope. PHP must use the GLOBAL keyword to obtain the global variable or use the Super GLOBAL variable $ global to access the external variable value. The C language is relatively simple. if the same variable name is not found in the local scope, the value of the variable declared externally is accessed.
Different Initializer variables
In C syntax, global variables can only be initialized using a Constant Expression (Constant Expression. In PHP syntax, the initialization variable can use any expression.
Function nesting is different.
The C language does not allow nested functions. you can declare another function in a function body, but cannot define another function (but the gcc extension feature allows nested functions ). PHP allows nested definition functions. you can often see that another function is defined in the function body or in the IF statement, as long as the order of calling nested functions is ensured after the nested statements are run.
Reading (91) rating (0) View Comments