作为一个正常的程序员,会好几种语言是十分正常的,
相信大部分程序员也都会编写几句PHP程序,如果是WEB程序员,PHP一定是必备的,
即使你没用开发过大型软件项目,也一定多少了解它的语法。
在PHP的流行普及中,网上总结出了很多实用的PHP代码片段,这些代码片段在当你遇到类似的问题时,粘贴过去就可以使用,非常的高效,非常的省时省力。将这些程序员前辈总结出的优秀代码放到自己的知识库中,是一个善于学习的程序员的好习惯。

 
  1. <?php
  2.  
  3. /**
  4. * 时间:2015-8-6
  5. * 作者:River
  6. * 超级有用、必须收藏的PHP代码样例
  7. */
  8. class Helper {
  9.  
  10. /**
  11. * 友好显示var_dump
  12. */
  13. static public function dump($var, $echo = true, $label = null, $strict = true) {
  14. $label = ( $label === null ) ? '' : rtrim($label) . ' ';
  15. if (!$strict) {
  16. if (ini_get('html_errors')) {
  17. $output = print_r($var, true);
  18. $output = "<pre>" . $label . htmlspecialchars($output, ENT_QUOTES) . "</pre>";
  19. } else {
  20. $output = $label . print_r($var, true);
  21. }
  22. } else {
  23. ob_start();
  24. var_dump($var);
  25. $output = ob_get_clean();
  26. if (!extension_loaded('xdebug')) {
  27. $output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);
  28. $output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES) . '</pre>';
  29. }
  30. }
  31. if ($echo) {
  32. echo $output;
  33. return null;
  34. } else
  35. return $output;
  36. }
  37.  
  38. /**
  39. * 获取客户端IP地址
  40. */
  41. static public function getClientIP() {
  42. static $ip = NULL;
  43. if ($ip !== NULL)
  44. return $ip;
  45. if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  46. $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
  47. $pos = array_search('unknown', $arr);
  48. if (false !== $pos)
  49. unset($arr[$pos]);
  50. $ip = trim($arr[0]);
  51. } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
  52. $ip = $_SERVER['HTTP_CLIENT_IP'];
  53. } elseif (isset($_SERVER['REMOTE_ADDR'])) {
  54. $ip = $_SERVER['REMOTE_ADDR'];
  55. }
  56. // IP地址合法验证
  57. $ip = ( false !== ip2long($ip) ) ? $ip : '0.0.0.0';
  58. return $ip;
  59. }
  60.  
  61. /**
  62. * 循环创建目录
  63. */
  64. static public function mkdir($dir, $mode = 0777) {
  65. if (is_dir($dir) || @mkdir($dir, $mode))
  66. return true;
  67. if (!mk_dir(dirname($dir), $mode))
  68. return false;
  69. return @mkdir($dir, $mode);
  70. }
  71.  
  72. /**
  73. * 格式化单位
  74. */
  75. static public function byteFormat($size, $dec = 2) {
  76. $a = array("B", "KB", "MB", "GB", "TB", "PB");
  77. $pos = 0;
  78. while ($size >= 1024) {
  79. $size /= 1024;
  80. $pos++;
  81. }
  82. return round($size, $dec) . " " . $a[$pos];
  83. }
  84.  
  85. /**
  86. * 下拉框,单选按钮 自动选择
  87. *
  88. * @param $string 输入字符
  89. * @param $param 条件
  90. * @param $type 类型
  91. * selected checked
  92. * @return string
  93. */
  94. static public function selected($string, $param = 1, $type = 'select') {
  95.  
  96. if (is_array($param)) {
  97. $true = in_array($string, $param);
  98. } elseif ($string == $param) {
  99. $true = true;
  100. }
  101. if ($true)
  102. $return = $type == 'select' ? 'selected="selected"' : 'checked="checked"';
  103.  
  104. echo $return;
  105. }
  106.  
  107. /**
  108. * 获得来源类型 post get
  109. *
  110. * @return unknown
  111. */
  112. static public function method() {
  113. return strtoupper(isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET' );
  114. }
  115.  
  116. /**
  117. * 提示信息
  118. */
  119. static public function message($action = 'success', $content = '', $redirect = 'javascript:history.back(-1);', $timeout = 4) {
  120.  
  121. switch ($action) {
  122. case 'success':
  123. $titler = '操作完成';
  124. $class = 'message_success';
  125. $images = 'message_success.png';
  126. break;
  127. case 'error':
  128. $titler = '操作未完成';
  129. $class = 'message_error';
  130. $images = 'message_error.png';
  131. break;
  132. case 'errorBack':
  133. $titler = '操作未完成';
  134. $class = 'message_error';
  135. $images = 'message_error.png';
  136. break;
  137. case 'redirect':
  138. header("Location:$redirect");
  139. break;
  140. case 'script':
  141. if (empty($redirect)) {
  142. exit('<script language="javascript">alert("' . $content . '");window.history.back(-1)</script>');
  143. } else {
  144. exit('<script language="javascript">alert("' . $content . '");window.location=" ' . $redirect . ' "</script>');
  145. }
  146. break;
  147. }
  148.  
  149. // 信息头部
  150. $header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  151. <html xmlns="http://www.w3.org/1999/xhtml">
  152. <head>
  153. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  154. <title>操作提示</title>
  155. <style type="text/css">
  156. body{font:12px/1.7 "\5b8b\4f53",Tahoma;}
  157. html,body,div,p,a,h3{margin:0;padding:0;}
  158. .tips_wrap{ background:#F7FBFE;border:1px solid #DEEDF6;width:780px;padding:50px;margin:50px auto 0;}
  159. .tips_inner{zoom:1;}
  160. .tips_inner:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0;}
  161. .tips_inner .tips_img{width:80px;float:left;}
  162. .tips_info{float:left;line-height:35px;width:650px}
  163. .tips_info h3{font-weight:bold;color:#1A90C1;font-size:16px;}
  164. .tips_info p{font-size:14px;color:#999;}
  165. .tips_info p.message_error{font-weight:bold;color:#F00;font-size:16px; line-height:22px}
  166. .tips_info p.message_success{font-weight:bold;color:#1a90c1;font-size:16px; line-height:22px}
  167. .tips_info p.return{font-size:12px}
  168. .tips_info .time{color:#f00; font-size:14px; font-weight:bold}
  169. .tips_info p a{color:#1A90C1;text-decoration:none;}
  170. </style>
  171. </head>
  172.  
  173. <body>';
  174. // 信息底部
  175. $footer = '</body></html>';
  176.  
  177. $body = '<script type="text/javascript">
  178. function delayURL(url) {
  179. var delay = document.getElementById("time").innerHTML;
  180. //alert(delay);
  181. if(delay > 0){
  182. delay--;
  183. document.getElementById("time").innerHTML = delay;
  184. } else {
  185. window.location.href = url;
  186. }
  187. setTimeout("delayURL(\'" + url + "\')", 1000);
  188. }
  189. </script><div class="tips_wrap">
  190. <div class="tips_inner">
  191. <div class="tips_img">
  192. <img src="' . Yii::app()->baseUrl . '/static/images/' . $images . '"/>
  193. </div>
  194. <div class="tips_info">
  195.  
  196. <p class="' . $class . '">' . $content . '</p>
  197. <p class="return">系统自动跳转在 <span class="time" id="time">' . $timeout . ' </span> 秒后,如果不想等待,<a href="' . $redirect . '">点击这里跳转</a></p>
  198. </div>
  199. </div>
  200. </div><script type="text/javascript">
  201. delayURL("' . $redirect . '");
  202. </script>';
  203.  
  204. exit($header . $body . $footer);
  205. }
  206.  
  207. /**
  208. * 查询字符生成
  209. */
  210. static public function buildCondition(array $getArray, array $keys = array()) {
  211. if ($getArray) {
  212. foreach ($getArray as $key => $value) {
  213. if (in_array($key, $keys) && $value) {
  214. $arr[$key] = CHtml::encode(strip_tags($value));
  215. }
  216. }
  217. return $arr;
  218. }
  219. }
  220.  
  221. /**
  222. * base64_encode
  223. */
  224. static function b64encode($string) {
  225. $data = base64_encode($string);
  226. $data = str_replace(array('+', '/', '='), array('-', '_', ''), $data);
  227. return $data;
  228. }
  229.  
  230. /**
  231. * base64_decode
  232. */
  233. static function b64decode($string) {
  234. $data = str_replace(array('-', '_'), array('+', '/'), $string);
  235. $mod4 = strlen($data) % 4;
  236. if ($mod4) {
  237. $data .= substr('====', $mod4);
  238. }
  239. return base64_decode($data);
  240. }
  241.  
  242. /**
  243. * 验证邮箱
  244. */
  245. public static function email($str) {
  246. if (empty($str))
  247. return true;
  248. $chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i";
  249. if (strpos($str, '@') !== false && strpos($str, '.') !== false) {
  250. if (preg_match($chars, $str)) {
  251. return true;
  252. } else {
  253. return false;
  254. }
  255. } else {
  256. return false;
  257. }
  258. }
  259.  
  260. /**
  261. * 验证手机号码
  262. */
  263. public static function mobile($str) {
  264. if (empty($str)) {
  265. return true;
  266. }
  267.  
  268. return preg_match('#^13[\d]{9}$|14^[0-9]\d{8}|^15[0-9]\d{8}$|^18[0-9]\d{8}$#', $str);
  269. }
  270.  
  271. /**
  272. * 验证固定电话
  273. */
  274. public static function tel($str) {
  275. if (empty($str)) {
  276. return true;
  277. }
  278. return preg_match('/^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/', trim($str));
  279. }
  280.  
  281. /**
  282. * 验证qq号码
  283. */
  284. public static function qq($str) {
  285. if (empty($str)) {
  286. return true;
  287. }
  288.  
  289. return preg_match('/^[1-9]\d{4,12}$/', trim($str));
  290. }
  291.  
  292. /**
  293. * 验证邮政编码
  294. */
  295. public static function zipCode($str) {
  296. if (empty($str)) {
  297. return true;
  298. }
  299.  
  300. return preg_match('/^[1-9]\d{5}$/', trim($str));
  301. }
  302.  
  303. /**
  304. * 验证ip
  305. */
  306. public static function ip($str) {
  307. if (empty($str))
  308. return true;
  309.  
  310. if (!preg_match('#^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $str)) {
  311. return false;
  312. }
  313.  
  314. $ip_array = explode('.', $str);
  315.  
  316. //真实的ip地址每个数字不能大于255(0-255)
  317. return ( $ip_array[0] <= 255 && $ip_array[1] <= 255 && $ip_array[2] <= 255 && $ip_array[3] <= 255 ) ? true : false;
  318. }
  319.  
  320. /**
  321. * 验证身份证(中国)
  322. */
  323. public static function idCard($str) {
  324. $str = trim($str);
  325. if (empty($str))
  326. return true;
  327.  
  328. if (preg_match("/^([0-9]{15}|[0-9]{17}[0-9a-z])$/i", $str))
  329. return true;
  330. else
  331. return false;
  332. }
  333.  
  334. /**
  335. * 验证网址
  336. */
  337. public static function url($str) {
  338. if (empty($str))
  339. return true;
  340.  
  341. return preg_match('#(http|https|ftp|ftps)://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?#i', $str) ? true : false;
  342. }
  343.  
  344. /**
  345. * 根据ip获取地理位置
  346. * @param $ip
  347. * return :ip,beginip,endip,country,area
  348. */
  349. public static function getlocation($ip = '') {
  350. $ip = new XIp();
  351. $ipArr = $ip->getlocation($ip);
  352. return $ipArr;
  353. }
  354.  
  355. /**
  356. * 中文转换为拼音
  357. */
  358. public static function pinyin($str) {
  359. $ip = new XPinyin();
  360. return $ip->output($str);
  361. }
  362.  
  363. /**
  364. * 拆分sql
  365. *
  366. * @param $sql
  367. */
  368. public static function splitsql($sql) {
  369. $sql = preg_replace("/TYPE=(InnoDB|MyISAM|MEMORY)( DEFAULT CHARSET=[^; ]+)?/", "ENGINE=\\1 DEFAULT CHARSET=" . Yii::app()->db->charset, $sql);
  370. $sql = str_replace("\r", "\n", $sql);
  371. $ret = array();
  372. $num = 0;
  373. $queriesarray = explode(";\n", trim($sql));
  374. unset($sql);
  375. foreach ($queriesarray as $query) {
  376. $ret[$num] = '';
  377. $queries = explode("\n", trim($query));
  378. $queries = array_filter($queries);
  379. foreach ($queries as $query) {
  380. $str1 = substr($query, 0, 1);
  381. if ($str1 != '#' && $str1 != '-')
  382. $ret[$num] .= $query;
  383. }
  384. $num++;
  385. }
  386. return ($ret);
  387. }
  388.  
  389. /**
  390. * 字符截取
  391. *
  392. * @param $string
  393. * @param $length
  394. * @param $dot
  395. */
  396. public static function cutstr($string, $length, $dot = '...', $charset = 'utf-8') {
  397. if (strlen($string) <= $length)
  398. return $string;
  399.  
  400. $pre = chr(1);
  401. $end = chr(1);
  402. $string = str_replace(array('&', '"', '<', '>'), array($pre . '&' . $end, $pre . '"' . $end, $pre . '<' . $end, $pre . '>' . $end), $string);
  403.  
  404. $strcut = '';
  405. if (strtolower($charset) == 'utf-8') {
  406.  
  407. $n = $tn = $noc = 0;
  408. while ($n < strlen($string)) {
  409.  
  410. $t = ord($string[$n]);
  411. if ($t == 9 || $t == 10 || ( 32 <= $t && $t <= 126 )) {
  412. $tn = 1;
  413. $n++;
  414. $noc++;
  415. } elseif (194 <= $t && $t <= 223) {
  416. $tn = 2;
  417. $n += 2;
  418. $noc += 2;
  419. } elseif (224 <= $t && $t <= 239) {
  420. $tn = 3;
  421. $n += 3;
  422. $noc += 2;
  423. } elseif (240 <= $t && $t <= 247) {
  424. $tn = 4;
  425. $n += 4;
  426. $noc += 2;
  427. } elseif (248 <= $t && $t <= 251) {
  428. $tn = 5;
  429. $n += 5;
  430. $noc += 2;
  431. } elseif ($t == 252 || $t == 253) {
  432. $tn = 6;
  433. $n += 6;
  434. $noc += 2;
  435. } else {
  436. $n++;
  437. }
  438.  
  439. if ($noc >= $length) {
  440. break;
  441. }
  442. }
  443. if ($noc > $length) {
  444. $n -= $tn;
  445. }
  446.  
  447. $strcut = substr($string, 0, $n);
  448. } else {
  449. for ($i = 0; $i < $length; $i++) {
  450. $strcut .= ord($string[$i]) > 127 ? $string[$i] . $string[++$i] : $string[$i];
  451. }
  452. }
  453.  
  454. $strcut = str_replace(array($pre . '&' . $end, $pre . '"' . $end, $pre . '<' . $end, $pre . '>' . $end), array('&', '"', '<', '>'), $strcut);
  455.  
  456. $pos = strrpos($strcut, chr(1));
  457. if ($pos !== false) {
  458. $strcut = substr($strcut, 0, $pos);
  459. }
  460. return $strcut . $dot;
  461. }
  462.  
  463. /**
  464. * 描述格式化
  465. * @param $subject
  466. */
  467. public static function clearCutstr($subject, $length = 0, $dot = '...', $charset = 'utf-8') {
  468. if ($length) {
  469. return XUtils::cutstr(strip_tags(str_replace(array("\r\n"), '', $subject)), $length, $dot, $charset);
  470. } else {
  471. return strip_tags(str_replace(array("\r\n"), '', $subject));
  472. }
  473. }
  474.  
  475. /**
  476. * 检测是否为英文或英文数字的组合
  477. *
  478. * @return unknown
  479. */
  480. public static function isEnglist($param) {
  481. if (!eregi("^[A-Z0-9]{1,26}$", $param)) {
  482. return false;
  483. } else {
  484. return true;
  485. }
  486. }
  487.  
  488. /**
  489. * 将自动判断网址是否加http://
  490. *
  491. * @param $http
  492. * @return string
  493. */
  494. public static function convertHttp($url) {
  495. if ($url == 'http://' || $url == '')
  496. return '';
  497.  
  498. if (substr($url, 0, 7) != 'http://' && substr($url, 0, 8) != 'https://')
  499. $str = 'http://' . $url;
  500. else
  501. $str = $url;
  502. return $str;
  503. }
  504.  
  505. /*
  506. 标题样式格式化
  507. */
  508.  
  509. public static function titleStyle($style) {
  510. $text = '';
  511. if ($style['bold'] == 'Y') {
  512. $text .='font-weight:bold;';
  513. $serialize['bold'] = 'Y';
  514. }
  515.  
  516. if ($style['underline'] == 'Y') {
  517. $text .='text-decoration:underline;';
  518. $serialize['underline'] = 'Y';
  519. }
  520.  
  521. if (!empty($style['color'])) {
  522. $text .='color:#' . $style['color'] . ';';
  523. $serialize['color'] = $style['color'];
  524. }
  525.  
  526. return array('text' => $text, 'serialize' => empty($serialize) ? '' : serialize($serialize));
  527. }
  528.  
  529. // 自动转换字符集 支持数组转换
  530. static public function autoCharset($string, $from = 'gbk', $to = 'utf-8') {
  531. $from = strtoupper($from) == 'UTF8' ? 'utf-8' : $from;
  532. $to = strtoupper($to) == 'UTF8' ? 'utf-8' : $to;
  533. if (strtoupper($from) === strtoupper($to) || empty($string) || (is_scalar($string) && !is_string($string))) {
  534. //如果编码相同或者非字符串标量则不转换
  535. return $string;
  536. }
  537. if (is_string($string)) {
  538. if (function_exists('mb_convert_encoding')) {
  539. return mb_convert_encoding($string, $to, $from);
  540. } elseif (function_exists('iconv')) {
  541. return iconv($from, $to, $string);
  542. } else {
  543. return $string;
  544. }
  545. } elseif (is_array($string)) {
  546. foreach ($string as $key => $val) {
  547. $_key = self::autoCharset($key, $from, $to);
  548. $string[$_key] = self::autoCharset($val, $from, $to);
  549. if ($key != $_key)
  550. unset($string[$key]);
  551. }
  552. return $string;
  553. } else {
  554. return $string;
  555. }
  556. }
  557.  
  558. /*
  559. 标题样式恢复
  560. */
  561.  
  562. public static function titleStyleRestore($serialize, $scope = 'bold') {
  563. $unserialize = unserialize($serialize);
  564. if ($unserialize['bold'] == 'Y' && $scope == 'bold')
  565. return 'Y';
  566. if ($unserialize['underline'] == 'Y' && $scope == 'underline')
  567. return 'Y';
  568. if ($unserialize['color'] && $scope == 'color')
  569. return $unserialize['color'];
  570. }
  571.  
  572. /**
  573. * 列出文件夹列表
  574. *
  575. * @param $dirname
  576. * @return unknown
  577. */
  578. public static function getDir($dirname) {
  579. $files = array();
  580. if (is_dir($dirname)) {
  581. $fileHander = opendir($dirname);
  582. while (( $file = readdir($fileHander) ) !== false) {
  583. $filepath = $dirname . '/' . $file;
  584. if (strcmp($file, '.') == 0 || strcmp($file, '..') == 0 || is_file($filepath)) {
  585. continue;
  586. }
  587. $files[] = self::autoCharset($file, 'GBK', 'UTF8');
  588. }
  589. closedir($fileHander);
  590. } else {
  591. $files = false;
  592. }
  593. return $files;
  594. }
  595.  
  596. /**
  597. * 列出文件列表
  598. *
  599. * @param $dirname
  600. * @return unknown
  601. */
  602. public static function getFile($dirname) {
  603. $files = array();
  604. if (is_dir($dirname)) {
  605. $fileHander = opendir($dirname);
  606. while (( $file = readdir($fileHander) ) !== false) {
  607. $filepath = $dirname . '/' . $file;
  608.  
  609. if (strcmp($file, '.') == 0 || strcmp($file, '..') == 0 || is_dir($filepath)) {
  610. continue;
  611. }
  612. $files[] = self::autoCharset($file, 'GBK', 'UTF8');
  613. ;
  614. }
  615. closedir($fileHander);
  616. } else {
  617. $files = false;
  618. }
  619. return $files;
  620. }
  621.  
  622. /**
  623. * [格式化图片列表数据]
  624. *
  625. * @return [type] [description]
  626. */
  627. public static function imageListSerialize($data) {
  628.  
  629. foreach ((array) $data['file'] as $key => $row) {
  630. if ($row) {
  631. $var[$key]['fileId'] = $data['fileId'][$key];
  632. $var[$key]['file'] = $row;
  633. }
  634. }
  635. return array('data' => $var, 'dataSerialize' => empty($var) ? '' : serialize($var));
  636. }
  637.  
  638. /**
  639. * 反引用一个引用字符串
  640. * @param $string
  641. * @return string
  642. */
  643. static function stripslashes($string) {
  644. if (is_array($string)) {
  645. foreach ($string as $key => $val) {
  646. $string[$key] = self::stripslashes($val);
  647. }
  648. } else {
  649. $string = stripslashes($string);
  650. }
  651. return $string;
  652. }
  653.  
  654. /**
  655. * 引用字符串
  656. * @param $string
  657. * @param $force
  658. * @return string
  659. */
  660. static function addslashes($string, $force = 1) {
  661. if (is_array($string)) {
  662. foreach ($string as $key => $val) {
  663. $string[$key] = self::addslashes($val, $force);
  664. }
  665. } else {
  666. $string = addslashes($string);
  667. }
  668. return $string;
  669. }
  670.  
  671. /**
  672. * 格式化内容
  673. */
  674. static function formatHtml($content, $options = '') {
  675. $purifier = new CHtmlPurifier();
  676. if ($options != false)
  677. $purifier->options = $options;
  678. return $purifier->purify($content);
  679. }
  680.  
  681. }
  682.  
  683. ?>

原文:http://www.phpxs.com/post/4116

33个超级有用必须要收藏的PHP代码样例的更多相关文章

  1. 10个超级有用、必须收藏的PHP代码样例

    在PHP的流行普及中,网上总结出了很多实用的PHP代码片段,这些代码片段在当你遇到类似的问题时,粘贴过去就可以使用,非常的高效,非常的省时省力.将这些程序员前辈总结出的优秀代码放到自己的知识库中,是一 ...

  2. 超级有用的9个PHP代码片段

    在开发网站.app或博客时,代码片段可以真正地为你节省时间.今天,我们就来分享一下我收集的一些超级有用的PHP代码片段.一起来看一看吧! 1.创建数据URI 数据URI在嵌入图像到HTML / CSS ...

  3. 一些有用的github收藏(持续更新中...)

    1.facebook的c++开源库folly(Facebook open source library)介绍 https://github.com/facebook/folly 2.pprint 一个 ...

  4. Python 100个样例代码【爆肝整理 建议收藏】

    本教程包括 62 个基础样例,12 个核心样例,26 个习惯用法.如果觉得还不错,欢迎转发.留言. 一. Python 基础 62 例 1 十转二 将十进制转换为二进制: >>> b ...

  5. 网页制作中最有用的免费Ajax和JavaScript代码库

    网上看到的一篇小文,挺有用的,收藏在这. 本文中,我整理了12个免费的Ajax和JavaScript代码库,可以帮助Web开发人员将应用程序提升到一个新水平. Ajax Instant Messeng ...

  6. 设为首页 和 收藏本站js代码 兼容IE,chrome,ff

    设为首页 和 收藏本站js代码 兼容IE,chrome,ff //设为首页 function SetHome(obj,url){ try{ obj.style.behavior='url(#defau ...

  7. 兼容所有浏览器的设为首页收藏本站js代码

    大家发现传统的收藏本站按钮在360浏览器下面没有效果了,但是360浏览器用户群却非常之大.所以我们在网上找到一个兼容所有浏览器的收藏本站解决方案,具体功能如下: 设为首页 和 收藏本站js代码 兼容I ...

  8. java 泛型深入之Set有用工具 各种集合泛型深入使用演示样例,匿名内部类、内部类应用于泛型探讨

    java 泛型深入之Set有用工具 各种集合泛型深入使用演示样例,匿名内部类.内部类应用于泛型探讨 //Sets.java package org.rui.generics.set; import j ...

  9. AppCan移动应用开发平台新增9个超有用插件(内含演示样例代码)

    使用AppCan平台进行移动开发.你所须要具备的是Html5+CSS +JS前端语言基础.此外.Hybrid混合模式应用还需结合原生语言对功能模块进行封装,对于没有原生基础的开发人员,怎样实现App里 ...

随机推荐

  1. 支持同步滚动的RichTextbox控件

    using System.Windows.Forms; public class SynchronizedScrollRichTextBox : System.Windows.Forms.RichTe ...

  2. ant windows环境配置

    详见如下链接,小蚂蚁builder.xml--apache-ant的配置 http://blog.csdn.net/gaohuanjie/article/details/40142687

  3. ASP.NET 正则替换URL参数值

    public class HomeController : Controller { public ActionResult Index() { var url = "http://www. ...

  4. Django Admin

    //设置admin列表名称 def __str__(self): return u'%s' % self.name class Meta: db_table ="数据库的那个表" ...

  5. NBUT 1457 莫队算法 离散化

    Sona Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Submit Status Practice NBUT 145 ...

  6. cocos2d-x3.x自定义事件

    -- 自定义事件 -- 监听: local eventDispatcher = self:getEventDispatcher();--self为继承Node的对象 local function ha ...

  7. 【codeforces 442B】 Andrey and Problem

    http://codeforces.com/problemset/problem/442/B (题目链接) 题意 n个人,每个人有p[i]的概率出一道题.问如何选择其中s个人使得这些人正好只出1道题的 ...

  8. Linux CentOS6.x ip设置(网卡设置)

    修改IP永久生效按以下方法vi /etc/sysconfig/network-scripts/ifcfg-eth0(eth0,第一块网卡,如果是第二块则为eth1)按如下修改ip: DEVICE=et ...

  9. 无限制使用ppt转pdf功能

    https://smallpdf.com/cn是一个pdf处理网站,十分好用,可是非注册用户有很多限制,比如用两次ppt转pdf就要等待: 于是就想如何让服务器认为我没有用过这个功能呢,感觉应该是用c ...

  10. Android 千牛数据库分析

    标签(空格分隔): 千牛,逆向 问题:Android 千牛登陆后产生保存用户数据的db无法直接用sqlite3打开,需要解密. 反编译Apk后jd-gui查看源码.熟悉的sqlcrypto模块加密,阿 ...