C Language and PHP syntax differences Point Technology
Maybe yes posted on 2015-02-05 16:09
Original link: http://blog.lmlphp.com/archives/80 from: lmlphp backyard
PHP's grammar rules are very similar to the C syntax rules, and many of the internal functions in PHP are called native C-language functions. Because the two languages run differently, there are some cases where there are some differences in syntax, as listed below.
Get global variables in different ways
To get the value of a global variable in scope, PHP must obtain it using the Global keyword or use the Hyper global variable $GLOBAL to access the value of the external variable. The C language is relatively simple, and in the local scope, the value of the externally declared variable is accessed without the same variable name.
Initialization (Initializer) variables are different
When a global variable is initialized in C syntax, it can only be initialized with a constant expression (Constant expression). In PHP syntax, an arbitrary expression can be used to initialize a variable.
function nesting is different
The C language does not allow nesting of defined functions, and another function can be declared in one function body, but another function cannot be defined (but GCC's extended attributes allow nested definition functions). PHP allows for nested definition functions, and you can often see that another function is defined in the body of a function or an if statement, as long as the sequence of nested functions is guaranteed to be called after the nested statement is run.
Read (91) reviews (0) View comments
C Language and PHP syntax differences