Skip to content

Instantly share code, notes, and snippets.

@trych
Created October 5, 2022 21:53
Show Gist options
  • Save trych/b96b8763e336039cef5f0f0d6d056a2b to your computer and use it in GitHub Desktop.
Save trych/b96b8763e336039cef5f0f0d6d056a2b to your computer and use it in GitHub Desktop.
getkirby e() helper function that does not throw error on undefined variable
<?php
function e(&$condition, $value, $alternative = null) {
echo $condition ? $value : $alternative;
}
$class = "banana";
e($class, 'class="' . $class . '"');
e($anotherClass, 'class="' . $anotherClass . '"');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment