convert_chars()

转换一些字符

描述

将字符串转换为一系列字符。

该函数移除Metadata标签<title> 和<category>,将 <br> 和<hr>转换为相应的XHTML,将统一码字符转换为可用值。

转换一些字符:

<title> 和 <category> 这些标签将会被删除<br> 和 <hr> 被转换成 <br /> 和 <hr /> 这样正确的写法。

一些 Unicode 的字符转换到转换到有效范围内。

用法

<?php convert_chars( $content, $deprecated ) ?>

参数

$content

(string) (必填) 需要转换的字符串

默认值: None

$deprecated

(string) (可选) 舍弃的参数,不再使用。

默认值: ”

返回值

(string) 

转换之后的字符串。

历史

添加于 版本: 0.71

源文件

convert_chars() 函数的代码位于 wp-includes/formatting.php.

/* ———————————-
* wordpress函数 星空站长网 收集
* ———————————- */
/**
* Converts lone & characters into `&` (a.k.a. `&`)
*
* @since 0.71
*
* @param string $content    String of characters to be converted.
* @param string $deprecated Not used.
* @return string Converted string.
*/

function convert_chars( $content, $deprecated = ” ) {

if ( ! empty( $deprecated ) ) {

_deprecated_argument( __FUNCTION__, ‘0.71’ );

}

if ( strpos( $content, ‘&’ ) !== false ) {

$content = preg_replace( ‘/&([^#])(?![a-z1-4]{1,8};)/i’, ‘&$1’, $content );

}

return $content;

}
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索