← All docs

htmlspecialchars()

Converts the HTML special characters in a string into their entities.

htmlspecialchars()

function htmlspecialchars(string $string, int $flags = 11, string $encoding = 'UTF-8'): string

Converts the HTML special characters in a string into their entities.

Parameters:

  • $string (string)
  • $flags (int), default 11, optional
  • $encoding (string), default 'UTF-8', optional

Returns: string

No examples yet — check examples/ and showcases/ for usage patterns.

Internals

For how htmlspecialchars is implemented in the compiler, see the internals page.