modX.paramValueIsTrue
Последнее обновление Oct 11th, 2026 | История страницы | Улучшить эту страницу | Сообщить о проблеме
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn moremodX::paramValueIsTrue¶
Читает $params[$key] и принимает только true, 'true', 1 и '1'. Всё остальное считается ложью, включая отсутствующий ключ, 'TRUE', 'on' и 'yes'.
Используйте $returnBoolAsString, когда результат попадает в генерируемый код: JavaScript, собранный через nowdoc или heredoc, не принимает литерал boolean PHP.
Синтаксис¶
bool paramValueIsTrue (array $params, string|int $key, [bool $returnBoolAsString = false])
-
$params(array) параметры для чтения -
$key(string|int) ключ для проверки -
$returnBoolAsString(bool) вернуть'true'или'false'вместо boolean, по умолчаниюfalse
Пример¶
$props = array('grow' => 'true', 'resize' => '0');
$grow = $modx->paramValueIsTrue($props, 'grow'); // true
$resize = $modx->paramValueIsTrue($props, 'resize'); // false
$flag = $modx->paramValueIsTrue($props, 'grow', true); // 'true'
Смотрите также¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn more










