【php生成缩略图示例代码分享(使用gd库实现)_php实例】教程文章相关的互联网学习教程文章

php数学函数的简单示例代码

php数学函数的小例子-bbs.it-home.orgecho abs(-1);//取绝对值函数echo "########ceil、floor函数######";echo ceil(1);//取大于参数的最小整数echo ceil(-1.1);echo "";echo floor(1.1);//取小于参数的最大整数echo floor(-1.1);echo "########max函数######";echo max(1,2);//取1和2的最大值echo "";$arr=array(1,2,3,4,5,7,6);echo max($arr);//取整型数组里的最大值echo "########pow函数######";echo pow(5,2);//输出5的2次方...

php日期函数的简单示例代码

php日期函数的小例子-bbs.it-home.orgecho time();//输出从1970年1月1日0时0分0秒到当前时间的秒数(时间戳)echo "";echo mktime(23,56,59,12,20,1999);//输出指定时间(时分秒月日年)的时间戳echo mktime(23,56,59,13,20,1999);//时间超出,往下推算echo "#------------strtotime函数-----------------#";echo strtotime("2009-10-12 20:20:29");//把指定的时间日期转化为时间戳,月日年的连接//只能用-或者/,时分秒的连接只能是:ec...

php实现文件下载、支持中文文件名的示例代码

/*---------------- * $FileName 为文件名称,必传 * $FilePath 为文件路径.选填,可以为相对路径或者绝对路径 * @路径只能由英文跟数据组成,不能带有中文 * @编辑整理:bbs.it-home.org ------------------*/ header("Content-type: text/html;charset=utf-8"); if(strlen($FileName) $FileName=iconv("utf-8","gb2312",$FileName);//进行文件名格式转换,以防中文乱码 //开始判断路径 if(!is_null($FilePath)&&strlen($FilePath)>1...

php获取图片的exif信息的示例代码

/*** 获取图片的exif信息* edit: bbs.it-home.org*/echo "test1.jpg:\n";$exif = exif_read_data('tests/test1.jpg', 'IFD0');echo $exif===false ? "No header data found.\n" : "Image contains headers\n"; $exif = exif_read_data('tests/test2.jpg', 0, true);echo "test2.jpg:\n";foreach ($exif as $key => $section) { foreach ($section as $name => $val) { echo "$key.$name: $val\n"; }}?>输出结果: tes...

PHP上传图片、删除图片的简单示例代码

<?phpif (!empty($_FILES["img"]["name"])) { //提取文件域内容名称,并判断 $path=”uppic/”; //上传路径 if(!file_exists($path)) { //检查是否有该文件夹,如果没有就创建,并给予最高权限 mkdir(“$path”, 0700); }//END IF //允许上传的文件格式 $tp = array(“image/gif”,”image/pjpeg”,”image/jpeg”); //检查上传文件是否在允许上传的类型 if(!in_array($_FILES["img"]["type"],$tp)) { echo “”; exit; }//END IF ...

php字符串函数的简单示例代码

/*** PHP 字符串函数 示例* by bbs.it-home.org*/$str1="aBCD";print($str1);//输出函数,有返回结果(字符串),速度没有echo 快!//可以说echo不是PHP函数print_r($str);//输出函数,一般用于测试echo "****".ord($str1)."";$str2="aBCD";echo "****".ord($str2)."";echo strcmp($str2,$str1);//str1的第一字母a的ASCII码值是否大于str2第一个字母的ASCII码值//是返回1,不是返回-1,相同的字母ASCII码值继续比较!完全相同返回0...

php文件下载(防止中文文件名乱码)的示例代码

<?php/*** php文件下载代码,中文无乱码* by bbs.it-home.org*/ $file = "/tmp/中文名.tar.gz"; $filename = basename($file); header("Content-type: application/octet-stream"); //处理中文文件名 $ua = $_SERVER["HTTP_USER_AGENT"]; $encoded_filename = urlencode($filename); $encoded_filename = str_replace("+", "%20", $encoded_filename); if (preg_match("/MSIE/", $ua)) { header(Co...

php连接oracle数据库的示例代码

if ($conn=OCILogon("kai","fjelite","linux")){ echo "SUCCESS ! Connected to database/n";}else{echo "Failed :-( Could not connect to database/n";}$stmt = OCIParse($conn,"select tel,AREA from hkh_tel "); OCIDefineByName($stmt,"TEL",&$TEL); OCIDefineByName($stmt,"AREA",&$AREA); OCIExecute($stmt); while ( // bbs.it-home.org OCIFetch($stmt)){ echo "TEL:".$TEL."/t"; echo "AREA:".$AREA."/n";}O...

php读取与下载csv文件的示例代码

<?php$fileName = "prefs.csv";header(Content-Type: application/octet-stream);header(Content-Disposition: attachment; filename= . $fileName);header(Content-Transfer-Encoding: binary);header(Content-Length: . filesize($fileName));readfile($fileName);例2,字符串形式下载csv文件。<?php$fileName = "pref_" . date("YmdHis") . ".csv";header(Content-Type: application/octet-stream);header(Content-Disposition...

php检测上传excel文件类型的示例代码

<?php/** * Detect upload file type * 检测上传文件的excel文件类型 * @param array $file * @return bool $flag * @site bbs.it-home.org */ private function detectUploadFileMIME($file) { // 1.through the file extension judgement 03 or 07 $flag = 0; $file_array = explode ( ".", $file ["name"] ); $file_extension = strtolower ( array_pop ( $file_array ) ); // 2...

phpexcel导入excel数据的示例代码

<php/** * 导入商品基本信息 * edit: bbs.it-home.org*/ public function importProductBasicInfo($data){ include_once PHPExcel.php; include_once PHPExcel/IOFactory.php; include_once PHPExcel/Reader/Excel5.php; // 定义一个错误集合. $error = array(); $resultInfo = null; $needNext = true; //上传文件到服务器指定位置 $fileName = $_FILES["prod...

phpcurl伪造IP的示例代码

#!/bin/awk -f #运行前 BEGIN { FS = " "; count = 0; } #运行中 { iparr[count ++] = $0; } #运行后 END { printf("<?php\n"); printf("$iparr = array(\n"); for (i = 0; i < count; i ++) { printf("%s => %s,\n", iparr[i], iparr[i]); } printf(");\n"); } 二,CURL使用<?php/*** CURL伪造IP地址访问* by bbs.it-home.org*/require_once dirname(__FILE__) ...

PHP模拟POST提交的示例代码

<?php/*** PHP中CURL模拟Post提交* by bbs.it-home.org*/$url = http://website/a.php;$fields = array(UserName=>urlencode(a),PWD=>urlencode(b) ,AppReturn=>urlencode(c) ,AppSQL=>urlencode(d) ,);$fields_string = http_build_query($fields);$ch = curl_init() ;curl_setopt($ch, CURLOPT_URL,$url) ; //设置要采集的URLcurl_setopt($ch, CURLOPT_POST,1) ; //设置形式为POST curl_setopt($ch, CURLOPT_POSTFIELDS,$field...

PHP导出带样式的Excel文件的示例代码

/*** 导出带有样式的excel* edit:bbs.it-home.org*/include 'Writer.php'; /* *** 准备导出的数据 *** */ $head = 'One Week Schedule'; $data = array('Monday' => array( array('time' => '09:00', 'event' => '公司例会例会'), array('time' => '14:00', 'event' => '部门例会') ), 'Tuesday' => a...

PHP批量更新数据库的示例代码

<?php/*** 批量更新数据库* by bbs.it-home.org*/for($i=1;$i<=$this->size;$i++){ $query[]="update tb_enterprise set eid=$eidex[$i] where eid=$i"; } $query_string=implode(";", $query); $query_result=$db->multi_query($query); if($query_result){ echo "Successed to update data!"; }else{ echo "Failed to update data!"; }

实例 - 相关标签