Content · Programming · PHP

PHP Normalizer::isNormalized() Method: Usage and Examples

Learn how to test whether a string is already in a specified Unicode normalization form in PHP with syntax, clear code examples, practical use, and common mistakes.

1 views Published Oct 16, 2026 Updated Oct 16, 2026

When working with PHP, you may need to test whether a string is already in a specified Unicode normalization form. This guide explains the operation, shows what its arguments mean, and uses three separate examples to make the result easier to understand.

Normalizer::isNormalized: Canonical forms let visually identical text use a consistent code-point representation.

What Is Normalizer::isNormalized in PHP?

Test whether a string is already in a specified Unicode normalization form. Canonical forms let visually identical text use a consistent code-point representation.

Syntax:

Normalizer::isNormalized(string $string, int $form = Normalizer::FORM_C): bool

Parameters and return value: The signature above identifies the arguments and return type where the API has a single call. For topic guides, follow the sequence of calls in the examples. Always distinguish a returned value from an object or variable modified by reference.

Important: Normalization does not remove dangerous markup or validate authorization. Choose compatibility forms only with a clear reason.

Example 1: Basic Usage

This example introduces the operation with a short and predictable input.

<?php

var_dump(Normalizer::isNormalized("é", Normalizer::FORM_C));

The code focuses on the main operation. Canonical forms let visually identical text use a consistent code-point representation.

Example 2: Another Case

Now compare a different input, locale, date, or option to see another part of the behavior.

<?php

var_dump(Normalizer::isNormalized("e\u{0301}", Normalizer::FORM_C));

What changes? Normalization does not remove dangerous markup or validate authorization. Choose compatibility forms only with a clear reason.

Practical Example: Applying It in an Application

Use the following separate example as a starting point for a small application task. Check any extension or environment requirements below before running it.

<?php

$userInput = "Cafe\u{0301}";
if (!Normalizer::isNormalized($userInput, Normalizer::FORM_C)) {
    $userInput = Normalizer::normalize($userInput, Normalizer::FORM_C);
}
echo $userInput;

The practical example demonstrates how to apply this operation to multiple values, a reusable task, or a validated input. Canonical forms let visually identical text use a consistent code-point representation.

Important Behavior and Edge Cases

  • Core behavior: Canonical forms let visually identical text use a consistent code-point representation.
  • Inputs and results: Normalization does not remove dangerous markup or validate authorization. Choose compatibility forms only with a clear reason.
  • Alternatives: Normalizer::normalize() produces normalized text rather than merely checking it.
  • Compatibility: The intl extension is required.

Comparison With Related Functions

Function or ApproachWhen to Use It
Normalizer::isNormalizedTest whether a string is already in a specified unicode normalization form.
Related PHP approachNormalizer::normalize() produces normalized text rather than merely checking it.

Common Beginner Mistakes

MistakeCorrect Approach
Using an incorrect input or optionNormalization does not remove dangerous markup or validate authorization. Choose compatibility forms only with a clear reason.
Confusing this API with a related operationNormalizer::normalize() produces normalized text rather than merely checking it.
Assuming output is identical across environmentsCheck return values and required extensions or versions. The intl extension is required.

Key Takeaways

  • Normalizer::isNormalized helps you test whether a string is already in a specified Unicode normalization form.
  • Canonical forms let visually identical text use a consistent code-point representation.
  • Normalization does not remove dangerous markup or validate authorization. Choose compatibility forms only with a clear reason.

Use Normalizer::isNormalized when you need to test whether a string is already in a specified Unicode normalization form. Start with the first example, compare the second, and adapt the practical example to your inputs. Confirm the return value and environment requirements before adding it to production code.

Share this resourceSend this page to someone who may find it useful.