<?php
Read Web page source code
$curl = Curl_init ();
curl_setopt ($curl, Curlopt_url, $url);
curl_setopt ($curl, Curlopt_header, 1);
curl_setopt ($curl, Curlopt_returntransfer, 1);
curl_setopt ($curl, Curlopt_ssl_verifypeer, false);//This is the point.
$contents = curl_exec ($curl);
Export as TXT file
$str = "ABCD";
$FP =fopen ("Pic.txt", "w");
Fputs ($fp, $STR);
Fclose ($FP);
Read table
Require_once ' excel_reader2.php ';
$data = new Spreadsheet_excel_reader ();
$data->setoutputencoding (' UTF-8 ');
$data->read ($filename);
for ($i =1; $i <= $data->sheets[0]["NumRows"]; $i + +) {
for ($j =1; $j <= $data->sheets[0][' numcols '); $j + +) {
[Email protected] $data->sheets[0][' cells ' [$i] [$j];
}
}
Read the file name of all files under the folder
$filedir = "c:/users/xia/desktop/new Folder/productinfolist/";
$rfdir = new Rdfile ($filedir);
$file = Implode ("\ r \ n", $rfdir->filelist);
Class rdfile{
Public $fileList; File names for all sub-folders
Public $ftype; Restricting the type of file
Public $dirlist; All file and folder names under the current folder.
function __construct ($path, $filetype = "*") {
if (!is_dir ($path)) {die ("This is not a directory");}
$len = strlen ($path)-1;
if ($path {$len} = = "/" | | $path {$len} = = "\") {$path = substr ($path, 0,-1);}
$this->ftype = $filetype;
$this->filelist = Array ();
$this->readypath ($path);
}
Public Function Readypath ($path) {
$dirList = Scandir ($path);
unset ($dirList [0]);
Unset ($dirList [1]);
$this->dirlist = $dirList;
foreach ($dirList as $key = = $value) {
$pathfile = $path. Directory_separator. $value;
if (Is_dir ($pathfile)) {
$this->readypath ($pathfile);
}else if (Is_file ($pathfile)) {
if ($this->ftype== "*") {
$this->filelist[] = $pathfile;
}else{
if (STRRCHR ($pathfile, ".") == ".". $this->ftype) {$this->filelist[] = $pathfile;}
}
}
}
}
}
?>
PHP read the source of the Web page, export to TXT file, read xls, read the file name of all files under the folder