Differences between C language and PHP syntax-php Tutorial

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

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.