在php中Constant与Define是常量那么下面我介绍一个方法能实现动态来使用Constant与Define值方法,希望对各位同学有所帮助.
PHP 要秀出 或 使用 动态 Constant / Define 值,要如何使用呢? 下述范例是动态变数,但是动态 Constant 要如何使用?代码如下:
<?php $a = 'abc'; $b = 'a'; echo $$b; // 印出 abc
PHP 使用 动态 Constant / Define 值,可以使用 constant() 来达成使用 Constant 的值,范例如下:
<?php define('PKEY1', 'abc'); define('PKEY2', 'def'); $i = 1; $a = 'PKEY'; echo constant($a . $i); // abc echo constant($a . ++$i); // def
教程地址:
欢迎转载!但请带上文章地址^^

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool