English 中文(简体)
preg_match and (non-English) Latin natures?
原标题:preg_match and (non-English) Latin characters?

我有一张X超文本,请人们填写他们的全名。 然后,我与<代码>preg_match()一致使用这一模式:/^[p{L}s]+$/

On my local server running PHP 5.2.13 (PCRE 7.9 2009-04-11) this works fine. On the webhost running PHP 5.2.10 (PCRE 7.3 2007-08-28) it doesn t match when the entered string contains the Danish Latin character ø ( http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=%F8&mode=char ).

这难道是一种ug吗? 是否有工作?

事先感谢你!

最佳回答

So, the problem is as presumed. You are not using the /u modifier. This means that PCRE will not look for UTF-8 characters.

无论如何,应当如何做到:

var_dump(preg_match( /^[p{L}s]+$/u , "ø")); 

我的所有版本都做了工作。 其他人可能会有ug,但这种情况不大可能。

您的问题是,这还有助于:

var_dump(preg_match( /^[p{L}s]+$/ , utf8_decode("ø")));

通知说,这使用ISO-8859-1而不是UTF-8,并删除了<代码>/u。 结果是int(1)。 英文字母缩略语 以非<代码>/u为格式。 (单一方位数×A0-xFF的多数是拉丁-1的字母符号,8位位代码与统法协会编码的相同,因此实际上ok。)

结论: 你的投入实际上是ISO-8859-1。 因此,它没有<代码>/u就意外地为你工作。 改变这种变化,并采用投入果园。

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签