Search⌘ K
AI Features

Checking If a String Contains Only ASCII Characters

Explore Laravel's isAscii helper method to determine if a string contains only ASCII characters. Learn how to use this for validating input, conditional processing, and combining with transliteration to handle non-ASCII strings in web applications.

We'll cover the following...

The isAscii helper method

We can use the isAscii helper method to check whether the provided string contains only ASCII characters. The results of this method can be useful to conditionally transliterate non-ASCII characters to their ASCII equivalents.

PHP
<?php
/**
* Versions: Laravel 8, 9
*
* @return bool
*/
public static function isAscii(
string $value
);

Some use ...