Defined () or define (); What does that mean?

Source: Internet
Author: User
How do I define it without defining it?
Is it similar to the if define in C language??
If you can find it in the PHP manual, please.
Like what:
defined('THINK_PATH') or define('THINK_PATH', dirname(__FILE__).'/');

Reply content:

How do I define it without defining it?
Is it similar to the if define in C language??
If you can find it in the PHP manual, please.
Like what:
defined('THINK_PATH') or define('THINK_PATH', dirname(__FILE__).'/');

There is also a "short circuit evaluation" of the knowledge points here.

PHP or C or many modern languages have this feature, in the calculation of logic or expression, the left side if true, then no longer calculate the right side, directly return true, so A or B; the effect can be achieved if(!A) B;

Similarly, when the logic is calculated, if the left side is false, then a short circuit is also taken, and the right side is not counted to return false A and B; likeif(A) B;

Short-circuit evaluation in the semantics of more close to English, but also to avoid the "if must be curly braces" brought about by the visual pollution (?), so it is more common practice (although not strictly in the sense of good habits)

http://php.net/manual/zh/function.defined.php
http://php.net/manual/zh/function.define.php

The =w= manual has ... defined () detects whether a constant name exists. return TRUE if defined returns False if not defined

Defined (' Think_path ') or define (' Think_path ', dirname (FILE). ' /');

First check that the constant think_path is defined, and if it is not defined, define a constant Think_path value dirname (FILE). ' /'

Similar to if (! A) {b} statement, but write to a or B words more introduction, if the definition of Think_path, then the condition is true, do not go behind, if not defined Think_path will go behind the statement.

  • 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.