本文整理汇总了PHP中obfuscate_text函数的典型用法代码示例。如果您正苦于以下问题:PHP obfuscate_text函数的具体用法?PHP obfuscate_text怎么用?PHP obfuscate_text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了obfuscate_text函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: obfuscate_mailto
/**
* This function uses the {@link obfuscate_email()} and {@link obfuscate_text()}
* to generate a fully obfuscated email link, ready to use.
*
* @param string $email The email address to display
* @param string $label The text to displayed as hyperlink to $email
* @param boolean $dimmed If true then use css class 'dimmed' for hyperlink
* @return string The obfuscated mailto link
*/
function obfuscate_mailto($email, $label = '', $dimmed = false)
{
if (empty($label)) {
$label = $email;
}
if ($dimmed) {
$title = get_string('emaildisable');
$dimmed = ' class="dimmed"';
} else {
$title = '';
$dimmed = '';
}
return sprintf("<a href=\"%s:%s\" {$dimmed} title=\"{$title}\">%s</a>", obfuscate_text('mailto'), obfuscate_email($email), obfuscate_text($label));
}
示例2: obfuscate_mailto
/**
* This function uses the {@link obfuscate_email()} and {@link obfuscate_text()}
* to generate a fully obfuscated email link, ready to use.
*
* @param string $email The email address to display
* @param string $label The text to displayed as hyperlink to $email
* @param boolean $dimmed If true then use css class 'dimmed' for hyperlink
* @param string $subject The subject of the email in the mailto link
* @param string $body The content of the email in the mailto link
* @return string The obfuscated mailto link
*/
function obfuscate_mailto($email, $label = '', $dimmed = false, $subject = '', $body = '')
{
if (empty($label)) {
$label = $email;
}
$label = obfuscate_text($label);
$email = obfuscate_email($email);
$mailto = obfuscate_text('mailto');
$url = new moodle_url("mailto:{$email}");
$attrs = array();
if (!empty($subject)) {
$url->param('subject', format_string($subject));
}
if (!empty($body)) {
$url->param('body', format_string($body));
}
// Use the obfuscated mailto.
$url = preg_replace('/^mailto/', $mailto, $url->out());
if ($dimmed) {
$attrs['title'] = get_string('emaildisable');
$attrs['class'] = 'dimmed';
}
return html_writer::link($url, $label, $attrs);
}
示例3: test_obfuscate_text
public function test_obfuscate_text()
{
$text = 'Žluťoučký koníček 32131';
$obfuscated = obfuscate_text($text);
$this->assertNotSame($text, $obfuscated);
$back = core_text::entities_to_utf8($obfuscated, true);
$this->assertSame($text, $back);
}
示例4: alter_email
function alter_email($matches)
{
return $matches[1] . obfuscate_text($matches[2]) . $matches[3];
}