本文汇集PHP开发中经常用到的十段代码,包括Email、64位编码和解码、解压缩、64位编码、解析JSON等,希望对您有所帮助。1、使用PHP Mail函数发送Email$to = "viralpatel.net@gmail.com";$subject = "VIRALPATEL.net";$body = "Body of your message here you can use HTML...
<?php if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){ echo 'systerm is IOS'; }else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android')){ ...
<?php $t = new executeTime; phpinfo(); class executeTime{ private $microtime; public function __construct(){ $this--->microtime = microtime(true); } pub...
下面是我写的代码,大家可以参考一下header("Content-type:text/html;charset=utf-8"); $name= isset($_FILES['file']['name'])?$_FILES['file']['name']:""; //图片名字 $size=isset($_FILES['file']['size'])?$...
生成JSON格式<?php header(‘content-type:application/json’); $number = array('1','2','3','4','5','6','7','8','9','0'); echo json_encode($number); //json_encode对变量进行 JSON 编码 ?> JSON格式的解析<?php hea...
一.只删除文件夹包含的文件,不删除文件夹public function deldir($dir) {//先删除目录下的文件: $dh = opendir($dir); while ($file = readdir($dh)) { if($file != "." && $file!="..") { $fullpath = ...
/**生成图片@param string $im 源图片路径@param string $dest 目标图片路径@param int $maxwidth 生成图片宽@param int $maxheight 生成图片高 */function resizeImage($im, $dest, $maxwidth, $maxheight) {$img = getimagesize($im); sw...
<?php /** * 抓取图片 * Class download_image * Time: 2019/1/31 13:49 * Author 江南极客 */ class download_image { public $save_path; //抓取图片的保存地址 //抓取图片的大小限制(单位:字节) 只抓比size比这个限制大的图片 ...
要使用cURL来发送url请求,具体步骤大体分为以下四步:1.初始化2.设置请求选项3.执行一个cURL会话并且获取相关回复4.释放cURL句柄,关闭一个cURL会话curl基础例子:<?php// 创建一个新cURL资源$ch = curl_init();// 设置URL和相应的选项curl_setopt($ch, CURLOPT_URL, "http://www.example.c...
curl请求参数设置时,CURLOPT_HTTPHEADER 设置 HTTP 头字段的数组。 格式: array('Content-type: text/plain', 'Content-length: 100')简单示例:function http_post($sUrl, $aHeader, $aData){$ch = curl_init(); curl_setopt($ch, CURLO...