PHP uses dynamic constant and define values _php tutorials

Source: Internet
Author: User
In PHP constant and define are constants then I would like to introduce a method to achieve dynamic use of constant and define value method, I hope you have some help.

How do you use PHP to show or use dynamic Constant/define values? Ex: The following example is a dynamic variable, but how is dynamic Constant used?

The code is as follows Copy Code


$a = ' abc ';
$b = ' a ';
echo $ $b; Print out ABC
?>


PHP uses dynamic constant/define values
You can use constant () to achieve a value using constant, as shown in the following example:

The code is as follows Copy Code

Define (' PKEY1 ', ' abc ');
Define (' PKEY2 ', ' def ');
$i = 1;
$a = ' PKEY ';
ECHO constant ($a. $i); Abc
ECHO constant ($a. + + $i); Def
?>

http://www.bkjia.com/PHPjc/632795.html www.bkjia.com true http://www.bkjia.com/PHPjc/632795.html techarticle in PHP constant and define are constants then I would like to introduce a method to achieve dynamic use of constant and define value method, I hope you have some help. PHP to show or use ...

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