It turns out that the :ascii:
expression is evaluated differently across the installation (however I'm not sure if it's on the operating system's end, or the PHP side, or brew, or something else).
Therefore, the issue can be solved in this instance by replacing /^[[:ascii:]]*$/u
expression with /^[\x00-\x7F]*$/u
. The full code is then:
<?php
$test = 'æhrzBGFX029!^%/\#,.';
if (preg_match('/^[\x00-\x7F]*$/u', $test)) {
echo 'ERR: this shouldn\'t have matched: \'' . $test . '\'';
} else {
echo 'OK';
}