當前位置: 首頁>>代碼示例>>PHP>>正文


PHP textlib::utf8_to_entities方法代碼示例

本文整理匯總了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("&#x17d;lu&#x165;ou&#x10d;k&#xfd; kon&#xed;&#x10d;ek&#xa9;\"&<>&#xa7;&#xab;", textlib::utf8_to_entities($str, false, true));
     $this->assertSame("&#381;lu&#357;ou&#269;k&#253; kon&#237;&#269;ek&#169;\"&<>&#167;&#171;", textlib::utf8_to_entities($str, true, true));
 }
開發者ID:masaterutakeno,項目名稱:MoodleMobile,代碼行數:13,代碼來源:textlib_test.php

示例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);
 }
開發者ID:masaterutakeno,項目名稱:MoodleMobile,代碼行數:46,代碼來源:graphlib.php


注:本文中的textlib::utf8_to_entities方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。