 |
ข้อแตกต่างสำหรับการตรวจสอบภาษาไทย ด้วย regular expression ด้วย PHP และ Javascript |
|
 |
|
|
 |
 |
|
ลืมใส่ u (utf-8 modifier) หรือเปล่าครับ?
Code (PHP)
<?php
if ($_POST) {
$char = ($_POST['char'] ?? '');
$checkResult = preg_match('/[^ก-๚]/u', $char);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<?php
if (isset($checkResult)) {
var_dump($checkResult);
}
?>
<form method="post">
<input type="text" name="char" value="<?php if (isset($char)) {echo htmlspecialchars($char, ENT_QUOTES);} ?>" autocomplete="off">
<button type="submi">Submit</button>
</form>
</body>
</html>
เกมส์ -> 0
เกมส์abc -> 1
|
ประวัติการแก้ไข 2020-06-03 20:35:11 2020-06-03 20:35:27
 |
 |
 |
 |
Date :
2020-06-03 14:30:44 |
By :
mr.v |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|