Skip to content

Instantly share code, notes, and snippets.

@rizkytegar
Last active January 31, 2024 04:57
Show Gist options
  • Save rizkytegar/8779a088867912b825f739a48923e990 to your computer and use it in GitHub Desktop.
Save rizkytegar/8779a088867912b825f739a48923e990 to your computer and use it in GitHub Desktop.
<?php
function e($value, $doubleEncode = true)
{
if ($value instanceof DeferringDisplayableValue) {
$value = $value->resolveDisplayableValue();
}
if ($value instanceof Htmlable) {
return $value->toHtml();
}
if ($value instanceof BackedEnum) {
$value = $value->value;
}
return htmlspecialchars($value ?? '', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8', $doubleEncode);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment