php 中双引号常量替换

php双引号字符串中可计算变量表达式,但是常量怎么办,可以使用如下方法:

define('ANIMAL', 'dog');
$constant = 'constant';
echo "I like {$constant('ANIMAL')}";

Total views.

© 2013 - 2024. All rights reserved.

Powered by Hydejack v6.6.1