随笔分类 -  php

摘要:这是xdebug的的错误报告。在开发环境下,可以考虑将其开启,但是在部署到真实应用环境下应该将其关掉。找到你的php.ini 在最后几行注释掉所有关于xdebug的东西,重启apache即可! 阅读全文
posted @ 2014-05-30 15:43 无忧之路 阅读(883) 评论(0) 推荐(0) 编辑
摘要:PHP获取图片大小函数。 getimagesize() 能够得到图片及flash(swf)的大小。语法1list($width, $height, $type, $attr) = getimagesize("image_name.jpg");下面是一个实例程序,将image_name.jpg改为您的图片地址01020304050607080910111213";echo"Image height ".$height;echo"";echo"Image type ".$type;echo"&quo 阅读全文
posted @ 2013-12-17 14:11 无忧之路 阅读(350) 评论(0) 推荐(0) 编辑
摘要:"set names utf8"));//最后一个参数使用utf8 }catch (PDOException $e) { echo "error:".$e->getMessage(); exit;}$result = $pdo->prepare("select * from t_user");$result->execute();$return = $result->fetchAll(PDO::FETCH_ASSOC);echo json_encode($return);?> 阅读全文
posted @ 2013-12-15 12:02 无忧之路 阅读(450) 评论(0) 推荐(0) 编辑
摘要:要知道两点:①浏览器传到PHP程序中是UTF-8编码②PHP程序保存上传的文件,要转换成GBK编码才保存在本地中,否则如果直接使用浏览器传过来的文件名保存在本地,会出现文件名乱码。 0) { echo "Return Code: " . $_FILES ["file"] ["error"] . ""; } else { $fileName = $_FILES ["file"] ["name"]; //将要保存在本地的文件名转成GBK编码,否则保存到本地时,本地文件为乱码 .. 阅读全文
posted @ 2013-12-11 16:52 无忧之路 阅读(685) 评论(0) 推荐(0) 编辑
摘要:链接:点击下载其中php:";if( empty($filename)){ echo''; exit();}if (!file_exists($filename)) { //检查文件是否存在 echo "文件找不到"; exit;} else { $file = fopen($filename,"r"); // 打开文件 // 输入文件标签 Header("Content-type: application/octet-stream"); Header("Accept-Ranges: bytes&q 阅读全文
posted @ 2013-12-11 16:29 无忧之路 阅读(859) 评论(0) 推荐(0) 编辑
摘要:@$time = $_GET['time'];if(empty($time)) { echo "empty";} else { echo "not empty";}或者将empty函数换成 !isset() 函数即可,记得前面有个取反符号 阅读全文
posted @ 2013-12-09 21:14 无忧之路 阅读(664) 评论(0) 推荐(0) 编辑
摘要:输出 ab字符串连接: .= 阅读全文
posted @ 2013-12-08 17:00 无忧之路 阅读(138) 评论(0) 推荐(0) 编辑
摘要:Filename: 0) { echo "Return Code: " . $_FILES ["file"] ["error"] . ""; } else { $tool = new GlobalTool (); $fileName = GlobalTool::getUploadName ( $_FILES ["file"] ["name"] ); move_uploaded_file ( $_FILES ["file"] ... 阅读全文
posted @ 2013-12-08 01:13 无忧之路 阅读(317) 评论(0) 推荐(0) 编辑
摘要:move_uploaded_file ( $_FILES ["file"] ["tmp_name"], "upload/" . $fileName);移动文件时要保证目标目录存在,否则报错. 阅读全文
posted @ 2013-12-08 01:11 无忧之路 阅读(246) 评论(0) 推荐(0) 编辑
摘要:$name = "tupian.png";$nameArr = explode(".", $name);习惯了Java的程序员容易写成$nameArr = explode("\\.", $name);//在PHP中是不正确的 阅读全文
posted @ 2013-12-07 23:37 无忧之路 阅读(228) 评论(0) 推荐(0) 编辑
摘要:如果表单中没有name参数,则会提示没有name这个参数(报了一个Notice),此时用抑制错误控制符 @ 来解决这个问题,然后使用isset()函数来判断是否传入了这个参数,如果没有传入这个参数,我们为之赋予一个默认值default 阅读全文
posted @ 2013-12-07 21:00 无忧之路 阅读(851) 评论(0) 推荐(0) 编辑
摘要:首先要安装phpmailer开源项目。将class.phpmailer.php转移到php文件夹下,编写代码:IsSMTP(); // 使用SMTP方式发送$mail->Host = "smtp.qq.com"; // 您的企业邮局域名$mail->SMTPAuth = true; // 启用SMTP验证功能$mail->Username = "645564675@qq.com"; // 邮局用户名(请填写完整的email地址)$mail->Password = "**********"; // 邮局密码$ma 阅读全文
posted @ 2013-10-27 21:23 无忧之路 阅读(485) 评论(0) 推荐(0) 编辑
摘要:smarty高级部分包括缓存机制和配置文件的调用下面是代码实现:文件一,配置文件:#全局变量title="网站主页"content="一个网站的主体部分"#在news中[news]title="新闻页面"content="新闻内容"#在forum中[news]title="论坛页面"content="论坛内容"文件二,php文件: template_dir = "./templates"; //模板存放目录 $smarty -> compile_di 阅读全文
posted @ 2013-10-27 00:26 无忧之路 阅读(285) 评论(0) 推荐(0) 编辑
摘要:insert用于模板中。用法:{insert name="method_name"}此时会寻找php文件中方法名为:insert_method_name的函数,将其返回值作为insert语句的值。例子: template_dir = "./templates"; //模板存放目录 $smarty -> compile_dir = "./templates_c"; //编译目录 $smarty -> cache_dir = "./cache"; //缓存目录 $smarty -> config_di 阅读全文
posted @ 2013-10-26 23:29 无忧之路 阅读(1393) 评论(0) 推荐(0) 编辑
摘要:require("Smarty.class.php"); $smarty = new Smarty(); $smarty -> template_dir = "./templates"; //模板存放目录 $smarty -> compile_dir = "./templates_c"; //编译目录 $smarty -> cache_dir = "./cache"; //缓存目录 $smarty -> config_dir = "./configs"; //缓存目录 阅读全文
posted @ 2013-10-26 01:34 无忧之路 阅读(357) 评论(0) 推荐(0) 编辑
摘要:文件:section.tpl{section name=color loop=$colors}{*这里是非关联数组,只是普通数组,这里的形式为:下标=>值 *}{$smarty.section.color.index} => {$colors[color]}{/section}文件:section.php template_dir = "./templates"; //模板存放目录 $smarty -> compile_dir = "./templates_c"; //编译目录 $smarty -> cache_dir = &qu 阅读全文
posted @ 2013-10-26 01:31 无忧之路 阅读(233) 评论(0) 推荐(0) 编辑
摘要:在template中,要注意{foreach from=$arr item=value}其中的value不需要$美元符号 阅读全文
posted @ 2013-10-26 00:30 无忧之路 阅读(216) 评论(0) 推荐(0) 编辑
摘要:定义和用法unlink() 函数删除文件。若成功,则返回 true,失败则返回 false。语法unlink(filename,context)参数描述filename必需。规定要删除的文件。context可选。规定文件句柄的环境。Context 是可修改流的行为的一套选项。 阅读全文
posted @ 2013-10-24 23:57 无忧之路 阅读(336) 评论(0) 推荐(0) 编辑
摘要:定义和用法realpath() 函数返回绝对路径。该函数删除所有符号连接(比如 '/./', '/../' 以及多余的 '/'),返回绝对路径名。若失败,则返回 false。比如说文件不存在的话。语法readlink(linkpath)参数描述linkpath必需。规定要检查的连接路径。说明在 BSD 系统上,如果仅仅是 linkpath 不存在的话,PHP 并不会像其它系统那样返回 false。例子输出:C:\Inetpub\testweb\test.txt 阅读全文
posted @ 2013-10-24 23:50 无忧之路 阅读(696) 评论(0) 推荐(0) 编辑
摘要:定义和用法file_exists() 函数检查文件或目录是否存在。如果指定的文件或目录存在则返回 true,否则返回 false。语法file_exists(path)参数描述path必需。规定要检查的路径。输出:1 阅读全文
posted @ 2013-10-24 23:50 无忧之路 阅读(524) 评论(0) 推荐(0) 编辑

无忧之路
点击右上角即可分享
微信分享提示