Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

php³£Óú¯Êý3


 
<?php
class useful{
 /*
  * ³£Óú¯ÊýÀà
  * ×÷    Õߣº¶à²ËÄñ
  * ÁªÏµÓÊÏ䣺kingerq AT msn DOT com
  * ´´½¨Ê±¼ä£º2005-07-18
  * À´Ô´£ºhttp://blog.csdn.net/kingerq
  */
 
 /*
  * ¹¦ÄÜ£º¸ñʽ»¯Êý×Ö£¬ÒÔ±ê×¼MONEY¸ñʽÊä³ö
  */
 
 function formatnumber($num){
  return number_format($num, 2, ".", ",");
 }
 
 /*
  * ¹¦ÄÜ£º¸ñʽ»¯Îı¾£¬½«\nת³É<br>µÈ
  * ²ÎÊý£º$string À´Ô´×Ö·û´®
  * ·µ»Ø£º´¦ÀíºóµÄ×Ö·û´®
  */
 function formatstring($string = ""){
  $string = preg_replace(array("/\s+/", "/\'/"), array(" ", "\"\""), $string);
  $string = htmlspecialchars($string);
  return nl2br($string);
 }
 
 /*
  * ¹¦ÄÜ£º¸ñʽ»¯Îı¾Êä³ö
  * ²ÎÊý $text ΪÐè¸ñʽ»¯µÄÎı¾ÄÚÈÝ
  *  É÷Óã¬Èç¹ûÈÃÓû§ÊäÈëµÄ¿ÉÖ´ÐдúÂëÔÚformatstring´¦Àíºó²åÈçÊý¾Ý¿â£¬È»ºóʹÓô˺¯Êý»áÈôúÂëÖ´ÐÐ
  */
 function formatcontent($text){
  $trans = get_html_translation_table(HTML_SPECIALCHARS);
  $trans = array_flip($trans);
  $text = strtr($text, $trans);
  //$text = str_replace("\n", "<br>", $text);
  //$text = str_replace(" ", "&nbsp;", $text);
  return $text;
 }
 
 /*
  * ½«×Ö½Úת»»³ÉKb»òÕßMb...
  * ²ÎÊý $numΪ×Ö½Ú´óС
  */
 function bitsize($num){
  if(!preg_match("/^[0-9]+$/", $num)) return 0;
  $type = array( "B", "KB", "MB", "GB", "TB", "PB" );
 
  $j = 0;
  while( $num >= 1024 ) {
   if( $j >= 5 ) return $num.$type[$j];
   $num = $num / 1024;
   $j++;
  }
  return $num.$type[$j];
 }
 
 /*
  * ¹¦ÄÜ£º²»×ã3µÄ±¶ÊýλµÄÊý×Ö£¬ÓÃ0²¹×ã
  * $num Ðè²¹³äµÄÊý×Ö
  * ·µ»Ø²¹³äÍêÕûµÄÊý×Ö´®
  */
 function prefix($num){
  if( strlen( $num ) % 3 == 0 ) {
   return $this-


Ïà¹ØÎĵµ£º

»ùÓÚPHPµÄÐÂWeb¿ª·¢¿ò¼Ü

±¾ÎÄת×Ô:http://www.msphome.cn/post/119/
    ×î½üÒòΪҪ¶ÔÒ»¸öÏîÄ¿½øÐÐÖع¹£¬ËùÒÔÒ»Ö±ÔÚÑо¿PHP¿ò¼Ü¡£´óÌå¿´ÁË¿´Zend Frameworks£¬×ÐϸѧϰÁËÏÂsymfony£¬·¢ÏÖÒ»¸öÁ¼ºÃµÄMVC Web¿ò¼Ü£¬×ãÒԸı俪·¢Ï°¹ß¡£µ«ÊÇÎÞÂÛÊÇZend Frameworks»¹ÊÇsymfony£¬¶ÔÓÚÖÐСÐÍÏîÄ¿µÄ¿ª·¢À´Ëµ¶¼¹ýÓÚÓ·Ö×£¬²¢²»ÄܺܺõÄÌáÉý¿ª· ......

PHP ÖÐ in_array º¯ÊýµÄÓ÷¨Óë×¢ÒâÏî

in_array(value,array,type)
in_array ×÷ÓÃÊÇÓÃÓڲ鿴 value ÊÇ·ñÔÚ array ÖдæÔÚ£¬Èç¹û²ÎÊý value ÊÇ×Ö·û´®£¬ÇÒ type ²ÎÊýÉèÖÃΪ true£¬ÔòËÑË÷Çø·Ö´óСд¡£Ôò in_array ÊÇ Çø·Ö´óСд µÄ¡£
ÓÐÒ»µãÐèҪעÒ⣬µ± array Öаüº¬ value µÄÖµ£¬Ôò·µ»Ø true£» µ«ÊÇ£¬Èç¹ûÁ½Õß²ÎÊýÖ®¼äÏàµÈ£¬Ôò·µ»Ø false
ÀýÈ磺
$str = 'a';
......

php³£Óú¯Êý2

Îļþ¶ÁÈ¡º¯Ê½
   //Îļþ¶ÁÈ¡º¯Ê½
   function PHP_Read($file_name) {
   $fd=fopen($file_name,r);
   while($bufline=fgets($fd, 4096)){
   $buf.=$bufline;
    }
   fclose($fd);
   return $buf;
    }
& ......

php³£Óü¼ÇÉ

ÈçºÎÅжÏipµØÖ·ºÏ·¨ÐÔ
if(!strcmp(long2ip(sprintf("%u",ip2long($ip))),$ip)) echo "is ipn";
 emailµÄÕýÔòÅжÏ
eregi("^[_.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z_-]+.)+[a-zA-Z]$", $email);
¼ì²âipµØÖ·ºÍmaskÊÇ·ñºÏ·¨µÄÀý×Ó
$ip = '192.168.0.84';
$mask = '255.255.255.0';
$network = '192.168.0';
$ip = ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ