分类目录归档:PHP

在 CDATA 节中找到无效的 XML 字符 (Unicode: 0x1f)

https://blog.csdn.net/dufufd/article/details/53895764

在 CDATA 节中找到无效的 XML 字符 (Unicode: 0x1f)

String could not be parsed as XML

解析XML文件时,会碰到程序发生以下一些异常信息: 

在 CDATA 节中找到无效的 XML 字符 (Unicode: 0x1f)。

或者:

An invalid XML character (Unicode: 0x1f) was found in the CDATA section.

这些错误的发生是由于一些不可见的特殊字符的存在,而这些字符对于XML文件来说又是非法的,所以XML解析器在解析时会发生异常,官方定义了XML的无效字符分为三段: 

0x00 – 0x08

0x0b – 0x0c

0x0e – 0x1f

解决方法是:在解析之前先把字符串中的这些非法字符过滤掉即可, 不会影响原来文本的内容。

即:string.replaceAll(“[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]”, “”) ;

# php 版过滤方法
$content2 = preg_replace(‘/[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]/mu’, ”, $content);

另外:这些字符即使放在CDATA中仍然解析不了,所以最好的办法是过滤掉。

正则零宽断言

https://blog.csdn.net/u010801439/article/details/77921037

零宽断言表示匹配字符的时候再添加一些定位条件,使匹配更精准。

  • \w+(?=ing) 匹配以ing结尾的多个字符(不包括ing)
  • \w+(?!ing) 匹配不是ing结尾的多个字符
  • (?<=re)\w+ 匹配以re开头的多个字符(不包括re)
  • (?<!re)\w+ 匹配不是re开头的多个字符
  • (?<=\s)\d+(?=\s) 匹配两边是空白符的数字,不包括空白符

本文参考:https://www.w3cschool.cn/rxoyts/l17fcozt.html

正则表达式30分钟入门教程:

https://deerchao.cn/tutorials/regex/regex.htm

php编译问题

configure: error: jpeglib.h not found.

yum -y install libjpeg-devel

configure: error: xpm.h not found.

yum install libXpm-devel -y

configure: error: freetype-config not found.

yum install freetype-devel -y

configure: error: Unable to locate gmp.h

yum install gmp-devel -y

The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.

(1/1) Google_Service_Exception
{
"error": {
"errors": [
{
"domain": "androidpublisher",
"reason": "projectNotLinked",
"message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."
}
],
"code": 403,
"message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."
}
}

openssl_private_encrypt 最大只能加密117字符😂

On my PHP5 build, the limit is 117 characters (936 bits, strange number). That’s because public key encryption is CPU intensive, and meant to be used on short values. The idea is to use this function to encrypt a secret key that is in turn used to encrypt data using a more efficient algorithm, such as RC4 or TripleDES.openssl_public_encrypt

blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];

FORBIDDEN/12/index read-only / allow delete (api)

官方解决方法:

curl -XPUT -H "Content-Type: application/json" http://127.0.0.1:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

_all 可以改为自己的索引名称,也可以直接执行

curl -XPUT -H "Content-Type: application/json" http://127.0.0.1:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

原文链接:https://www.cnblogs.com/zhja/p/9717536.html