C Language and PHP syntax differences

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.