¼¸¸ö PHP Îļþ¶Áдº¯ÊýºÍ CSVFileObject Àà
/**
* ´ò¿ª¹Ø±ÕÎļþ
*/
fopen() // 2/4: 2 ¸ö±ØÑ¡²ÎÊý£¬ 4 ¸ö²ÎÊý;
fclose() // 1/1;
/**
* ¶ÁÈ¡Îļþ
*/
// ÐèÏÈÓà fopen() ´ò¿ªÎļþ²ÅÄܶÁÈ¡µÄº¯Êý£»´ÓÎļþÖ¸Õë´¦¿ªÊ¼¶ÁÈ¡
fgetc() // 1/1; ¶ÁÈ¡Ò»¸ö×Ö·û
fgets() // 1/2; ¶ÁÈ¡Ò»ÐÐ
fgetss() // 1/3; ¶ÁÈ¡Ò»Ðв¢È¥³ý HMTL ±êÇ©
fgetcsv() // 1/5; ¶ÁÈ¡Ò»Ðв¢½âÎöΪ csv ×ֶΣ¬·µ»ØÊý×é
fread() // 2/2; ¶ÁÈ¡Ö¸¶¨×Ö½ÚµÄ×Ö·û
fscanf() // 2/n; ´ÓÎļþÖиñʽ»¯ÊäÈë
// ²»ÐèÒªÏÈ fopen() ´ò¿ªÎļþµÄº¯Êý
file() // 1/3; ¶ÁÈ¡Õû¸öÎļþÄÚÈݵ½Ò»¸öÊý×飬ÎļþÖÐÒ»ÐжÔÓ¦Êý×éÖÐÒ»¸öÔªËØ
file_get_contents() // 1/5; ¶ÁÈ¡Õû¸öÎļþµ½Ò»¸ö×Ö·û´®
readfile() // 1/3; ¶ÁÈëÒ»¸öÎļþ²¢Ð´Èëµ½Êä³ö»º³å¡£
/**
* дÈëÎļþ
*/
fwrite() / fputs() // 2/3; дÈëÎļþ£¨¿É°²È«ÓÃÓÚ¶þ½øÖÆÎļþ£©, ÐèÏÈ fopen()
fputcvs() // 2/4; ½«Ðиñʽ»¯Îª CSV ²¢Ð´ÈëÎļþÖ¸Õë,ÐèÏÈ fopen()
file_put_contents() // 2/4; ½«×Ö·û´®Õû¸öдÈëÎļþ
/**
* ÎļþÖ¸Õë
*/
ftell() // 1/1; ·µ»ØÎļþÖ¸Õë¶Á/дµÄλÖÃ
fseek() // 2/3; ÔÚÎļþÖ¸ÕëÖж¨Î»
rewind() // 1/1; µ¹»ØÎļþÖ¸ÕëµÄλÖÃ
/**
* ʹÓà SplFileObject ·½·¨ fgetcsv() ʱ×îºóÒ»ÐкóÃ滹»á½âÎö³öÒ»¸öÊý×é
* eg:
* $it = new SplFileObject('sample.csv');
* while( $arr = $it->fgetcsv() ){
* print_r( $arr)
* }
*/
class CSVFileObjectException extends Exception{
//
}
class CSVFileObject extends SplFileInfo implements Iterator{
protected $current_line;
protected $map;
protected $column_cnt;
protected $fp;
function __construct( $filename, $mode, $use_include_path = FALSE, $context = NULL)
{
$this->ensure( ! is_readable( $filename), "CSV file {$filename} does not exists or is not readable");
if( is_null( $context)){
$this->fp = @fopen( $filename, $mode, $use_include_path);
}else{
$this->fp = @fopen( $filename, $mode, $use_include_path, $context);
}
$this->ensure( ! $this->fp, "open CSV file {$filename} failure");
parent::__construct( $filename);
$this->current_line = 0;
$
Ïà¹ØÎĵµ£º
¹²3¸öÎļþ
IncDB.phpÊý¾Ý¿âÁ¬½Ó
index.phpÊ×Ò³
InsetToDB.phpÊý¾Ý¿â²Ù×÷
Êý¾Ý¿âlguestbookÀïÃ潨±í
CREATE TABLE `intd` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) character set utf8 collate utf8_bin N ......
Ò»¡¢°²×°
1. Ê×ÏÈ°²×°SSH
sudo apt-get install ssh
2.°²×°MySQL(ËäÈ»ÏÖÔÚ×îаæΪ5.1£¬µ«ÊÇ»¹Ö»ÄÜ×°5.0°æ±¾)
sudo apt-get install mysql-server-5.0
3.°²×°Apache
sudo apt-get install apache2
4.°²×°PHP
sudo apt-get install php5 libapache2-mod-php5
5.ÖØÆôApache
sudo /etc/init.d/apache2 restart ......
1¡¢Ç°ÑÔ
¡¡¡¡·ÖÒ³ÏÔʾÊÇÒ»Öַdz£³£¼ûµÄä¯ÀÀºÍÏÔʾ´óÁ¿Êý¾ÝµÄ·½·¨£¬ÊôÓÚweb±à³ÌÖÐ×î³£´¦ÀíµÄʼþÖ®Ò»¡£¶ÔÓÚweb±à³ÌµÄÀÏÊÖÀ´Ëµ£¬±àдÕâÖÖ´úÂëʵÔÚÊǺͺôÎüÒ»Ñù×ÔÈ»£¬µ«ÊǶÔÓÚ³õѧÕßÀ´Ëµ£¬³£³£¶ÔÕâ¸öÎÊÌâÃþ²»×ÅÍ·Ð÷£¬Òò´ËÌصØ׫д´ËÎĶÔÕâ¸öÎÊÌâ½øÐÐÏêϸµÄ½²½â£¬Á¦ÇóÈÿ´ÍêÕâƪÎÄÕµÄÅóÓÑÔÚ¿´ÍêÒÔºó¶ÔÓÚ·ÖÒ³ÏÔʾµÄÔ ......
Mysql×ÔÉíѧϰ
1.Êý¾Ý¿â³£ÓõÄ×Ö¶ÎÀàÐÍ£º
ÕûÊýÐÍ: TINYINT(0-255×Ö¶Î), SMALLINT(´óµã), INT(¸ü³¤), BIGINT;
СÊýÐÍ: FLOAT, BOUBLE, DECIMAL(M(ÕûÊý),D£¨Ð¡Êý£©);
×Ö·ûÐÍ: CHAR(¹Ì¶¨), VARCHAR(µ¯ÐÔ×Ö·ûÐÍ£¬¼õ»ºÈÝÁ¿);£¨××Ö·ûΪ255£©
ÈÕÆÚÐÍ: DATETIME£¨ÈÕÆÚʱ¼ä£©, DATE£¨ÈÕÆÚ£©, TIMESTAMP£¨ÈÕÆÚת»¯ÎªÊý×Ö.¾«¶È ......
½ñÌìÔÚ¼ÒÀïÖØа²×°ÁËÒ»ÏÂPHP µ±ÈÃÒ²ÓÐApacheÁË¡£µ«ÊÇÎÒÓöµ½ÁËÒ»¸öÎÊÌ⣬¾ÍÊÇApache·þÎñÎÞ·¨¿ªÆô£¬ºó¹ûÔõÑùÎÒÏëºÜ¶àÈ˶¼ÊÇÖªµÀµÄ£¬µ±Ê±Ò²Ã»ÓжàÏ룬ÒÔΪÊÇ×Ô¼º°²×°µÄʱºò³öÏÖÁËʧÎó¾ÍÖØа²×°Ò»±é£¬¿ÉÊÇ»¹ÊÇÒ»ÑùÎÞ·¨´ò¿ª£¬È»ºóÎÒ¾ÍÔÚÏëÊÇʲôÎÊÌ⣬¶Ë¿ÚºÅ80.ÎҲ鿴ÁËһϣ¬·¢ÏÖûÓдíÎó°¡£¬Ë¼¿¼Á˺ܾ㬶ÔÍøÂçÒÔ¼°·À» ......