php curl的几段小应用
php 的CURL是不错的功能,下面收藏几段不错的片段
1 测试网站是否运行正常
// open a file pointer$file = fopen("/path/to/file", "r");// the url contains most of the info needed$url = "ftp://username:password@mydomain.com:21/path/to/new/file";$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);// upload related optionscurl_setopt($ch, CURLOPT_UPLOAD, 1);curl_setopt($ch, CURLOPT_INFILE, $fp);curl_setopt($ch, CURLOPT_INFILESIZE, filesize("/path/to/file"));// set for ASCII mode (e.g. text files)curl_setopt($ch, CURLOPT_FTPASCII, 1);$output = curl_exec($ch);curl_close($ch);