PHP 8.4.24 Released!

Voting

: three plus one?
(Example: nine)

The Note You're Voting On

Anonymous
1 year ago
mb_ereg() cannot match over 100,000 (100K) characters (not bytes but characters)
whereas preg_match() can over 1,000,000,000 (1G, if it's within "memory_limit").
Try this.

<?php

ini_set("memory_limit", "512M"); // <-- must be changed if you try 1G.
$length = 100000; // <-- 99999 is OK / 100000 is NG

$str = "";
for ($i=0; $i<$length; $i++):
    $str .= "1"; // <-- same result if it is a multibyte character.
endfor;

if (mb_ereg('.*', $str)):
    echo '<br><span style="background-color:lightgreen">OK!</span><br>memory_limit = '.ini_get("memory_limit").'<br>$length = '.$length;
else:
    echo '<br><span style="background-color:orange">NG!</span><br>memory_limit = '.ini_get("memory_limit").'<br>$length = '.$length;
endif;

?>

<< Back to user notes page

To Top