- strtoupper: documentation ( source)
- constant: documentation ( source)
<?php
function pr($a) { echo $a . PHP_EOL; }
class ModuleConfig {
const PAYMENT_GATEWAY_MOLLIE_KEY = 'deadbeef';
}
$paymentGateway = 'MOLLIE';
$gatewayKey = 'ModuleConfig::PAYMENT_GATEWAY_' . strtoupper($paymentGateway) . '_KEY';
$foo = ModuleConfig::PAYMENT_GATEWAY_MOLLIE_KEY;
pr($foo); // prints the key
pr($gatewayKey); // prints ModuleConfig::PAYMENT_GATEWAY_MOLLIE_KEY
pr(constant($gatewayKey)); // tells me it cannot find a constant ModuleConfig::PAYMENT_GATEWAY_MOLLIE_KEY