Maison >développement back-end >tutoriel php > 学习遇到有关问题了,请过来人给予指点
学习遇到问题了,请过来人给予指点
当看框架源码时(例:ci)
遇到其中不懂的写法身边又没有牛人指点该怎么办?
就如下边这段代码:当strtolower($charset) != 'utf-8'时是一种处理,非而是另一种处理为什么那?像这样的问题如果到论坛里去咨询别人可能要等半天才能解决,如果搜索查找的话像这样的问题又没法下手。苦恼中..... 我该怎么办呢? 希望大家给予指点笔人感激不尽。
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> public function entity_decode($str, $charset='UTF-8') { if (stristr($str, '&') === FALSE) return $str; // The reason we are not using html_entity_decode() by itself is because // while it is not technically correct to leave out the semicolon // at the end of an entity most browsers will still interpret the entity // correctly. html_entity_decode() does not convert entities without // semicolons, so we are left with our own little solution here. Bummer. if (function_exists('html_entity_decode') && (strtolower($charset) != 'utf-8')) { $str = html_entity_decode($str, ENT_COMPAT, $charset); $str = preg_replace('~(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str); return preg_replace('~([0-9]{2,4})~e', 'chr(\\1)', $str); } // Numeric Entities $str = preg_replace('~(0*[0-9a-f]{2,5});{0,1}~ei', 'chr(hexdec("\\1"))', $str); $str = preg_replace('~([0-9]{2,4});{0,1}~e', 'chr(\\1)', $str); // Literal Entities - Slightly slow so we do another check if (stristr($str, '&') === FALSE) { $str = strtr($str, array_flip(get_html_translation_table(HTML_ENTITIES))); } return $str; }