[PHP] Conditional compilation definition in PHP source code, php source code

Source: Internet
Author: User

[PHP] Conditional compilation definition in PHP source code, php source code

The mechanism for Compiling different codes and generating different target files according to different situations is called Conditional compilation.
The following pre-processing commands are available: # if, # elif, # else # endif; # ifdef # else # endif

PHP source code:

# Ifdef SERIALIZE_HEADERS // if there is a macro definition SERIALIZE_HEADERS # define VEC_FREE () smart_str_free (& vec_str) // macro definition VEC_FREE () # else // if not # define VEC_FREE () do {} while (0) // macro definition empty operation # endif # ifdef DEBUG // If macro definition DEBUG # define LOG_MSG printf // macro definition LOG_MSG # else // if not # define LOG_MSG (...) // macro defines an empty operation # endif

Exercise:

# If _ WIN32 printf ("windows SYSTEM \ n"); # elif _ linux _ printf ("linux System \ n "); # else printf ("other systems \ n"); # endif # ifdef N printf ("macro definition N \ n "); # else printf ("macro definition N \ n does not exist"); # endif

 

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.