本文整理汇总了PHP中textlib::utf8_to_entities方法的典型用法代码示例。如果您正苦于以下问题:PHP textlib::utf8_to_entities方法的具体用法?PHP textlib::utf8_to_entities怎么用?PHP textlib::utf8_to_entities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类textlib
的用法示例。
在下文中一共展示了textlib::utf8_to_entities方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_utf8_to_entities
/**
* Tests the static utf8_to_entities method
* @return void
*/
public function test_utf8_to_entities()
{
$str = "Žluťoučký koníček©"&<>§«";
$this->assertSame("Žluťoučký koníček©"&<>§«", textlib::utf8_to_entities($str));
$this->assertSame("Žluťoučký koníček©"&<>§«", textlib::utf8_to_entities($str, true));
$str = "Žluťoučký koníček©"&<>§«";
$this->assertSame("Žluťoučký koníček©\"&<>§«", textlib::utf8_to_entities($str, false, true));
$this->assertSame("Žluťoučký koníček©\"&<>§«", textlib::utf8_to_entities($str, true, true));
}
示例2: get_boundaryBox
function get_boundaryBox($message)
{
$points = $message['points'];
$angle = $message['angle'];
$font = $this->parameter['path_to_fonts'] . $message['font'];
$text = $message['text'];
//print ('get_boundaryBox');
//expandPre($message);
// get font size
$bounds = ImageTTFBBox($points, $angle, $font, "W");
if ($angle < 0) {
$fontHeight = abs($bounds[7] - $bounds[1]);
} else {
if ($angle > 0) {
$fontHeight = abs($bounds[1] - $bounds[7]);
} else {
$fontHeight = abs($bounds[7] - $bounds[1]);
}
}
// get boundary box and offsets for printing at an angle
// start of Moodle addition
$text = textlib::utf8_to_entities($text, true, true);
//gd does not work with hex entities!
// end of Moodle addition
$bounds = ImageTTFBBox($points, $angle, $font, $text);
if ($angle < 0) {
$width = abs($bounds[4] - $bounds[0]);
$height = abs($bounds[3] - $bounds[7]);
$offsetY = abs($bounds[3] - $bounds[1]);
$offsetX = 0;
} else {
if ($angle > 0) {
$width = abs($bounds[2] - $bounds[6]);
$height = abs($bounds[1] - $bounds[5]);
$offsetY = 0;
$offsetX = abs($bounds[0] - $bounds[6]);
} else {
$width = abs($bounds[4] - $bounds[6]);
$height = abs($bounds[7] - $bounds[1]);
$offsetY = $bounds[1];
$offsetX = 0;
}
}
//return values
return array('width' => $width, 'height' => $height, 'offsetX' => $offsetX, 'offsetY' => $offsetY);
}