![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
php
文章平均质量分 53
montaellis
这个作者很懒,什么都没留下…
展开
-
php 数组转json,json转数组 json_encode json_decode 失败
json_encode() requires input that isnullinteger, float, booleanstring encoded as UTF-8objects implementing JsonSerializable (or whatever it's called, I'm too lazy to look it up)arrays of JSO原创 2017-11-03 14:38:44 · 903 阅读 · 0 评论 -
php错误处理
<?php//初始化错误的配置ini_set('error_reporting', E_ALL | E_STRICT);ini_set('display_errors', 1);//错误日志ini_set('error_log', 'e:/php1016/apache/htdocs/test/test.error.log');ini_set('log_errors', 1);//转载 2014-06-16 23:59:14 · 403 阅读 · 0 评论 -
素数测试
<?php/** * 判断是否为素数 * * @param $n int * * @return bool */function isPrime($n) { for($d=2,$sqrt=sqrt($n); $d<=$sqrt; ++$d) { if($n % $d == 0) { return false; } } return true;}//v转载 2014-06-20 01:05:08 · 522 阅读 · 0 评论 -
jsonp得到ip信息
IP地址:">原创 2014-04-10 17:05:51 · 1329 阅读 · 0 评论 -
php排序函数
sort() 函数按升序对给定数组的值排序。注释:本函数为数组中的单元赋予新的键名。原有的键名将被删除。如果成功则返回 TRUE,否则返回 FALSE。<?php$my_array = array("a" => "Dog", "b" => "Cat", "c" => "Horse");sort($my_array);print_r($my_array);?>outpu原创 2013-08-27 15:50:00 · 3147 阅读 · 0 评论 -
git
git常用命令1. 创建git资源库git init --bare 库名称2. 在用户文件夹下把资源clone下来git clone /g/software/repository/git/itheima .注意:clone时候用户目录必须为空3. 创建一个文件,纳入到版本控制中。git add 第一次执行会出警告:warning: LF will转载 2014-07-18 13:36:08 · 596 阅读 · 0 评论 -
thinkphp的RBAC
sql--用户表CREATE TABLE IF NOT EXISTS `sw_manager` ( `mg_id` int NOT NULL AUTO_INCREMENT, `mg_name` varchar(20) NOT NULL comment '名称', `mg_pwd` varchar(32) NOT NULL comment '密码', `mg_time` int转载 2014-05-28 21:57:37 · 1487 阅读 · 0 评论 -
$_SERVER获取设备,浏览器,操作系统信息
function get_server_info($para){ $agent = $phone_type = strtolower($_SERVER['HTTP_USER_AGENT']); if($para == 'device_type'){ //得到设备信息 $phone_type = strtolower($_SERVER['HTTP_USER_AGENT'])转载 2014-07-01 15:39:34 · 639 阅读 · 0 评论 -
百度云推送服务器端(php版)
<?phpnamespace Admin\Controller;use Think\Controller;use Org\Net;class AppController extends Controller{ private $appService; private $appPush; public function __construct(){ parent::__cons原创 2014-05-29 13:39:32 · 7927 阅读 · 2 评论 -
js加密的密文PHP解密(AES算法)
http://www.cnblogs.com/liulun/p/3543774.html转载 2014-06-11 14:11:56 · 6260 阅读 · 1 评论 -
pdo
pdo的基本操作<?php$dsn = 'mysql:dbname=itcast_shop;host=127.0.0.1;port=3306';$username = 'root';$password = '123456';$pdo = new PDO($dsn, $username, $password);//var_dump($pdo);$sql = "select *转载 2014-06-10 00:26:24 · 575 阅读 · 0 评论 -
php压缩图片尺寸,并转为jpg
<?phpfunction ImageToJPG($srcFile,$dstFile,$towidth,$toheight) { $quality=80; $data = @GetImageSize($srcFile); switch ($data['2']) { case 1: $im = imagecreatefromgif($srcFile); break转载 2014-06-08 17:51:08 · 3066 阅读 · 0 评论 -
无限分类[增强版]
/** +------------------------------------------------ * 通用的树型类 +------------------------------------------------ * @author yangyunzhou@foxmail.com +----------------------转载 2013-12-09 15:41:46 · 562 阅读 · 0 评论 -
gd库典型应用
简单缩略图<?php//创建原图画布和缩略图画布$src_file = './src.jpg';$src_img = imagecreatefromjpeg($src_file);//基于已有图片创建//缩略图的大小应该如何确定?$dst_img = imagecreatetruecolor(100, 100);//创建一个新的画布//采样,拷贝,修改大小imagecopyr转载 2014-06-16 22:08:37 · 426 阅读 · 0 评论 -
php虚拟主机配置、访问权限配置、分布式文件配置
通常情况下,一个web服务代理一个网站,但是有时候我们需要用一台服务器代理多个网站。这个就是基于域名的虚拟主机技术。 我们可以直接在httpd.conf当中进行配置,也可以使用extra中的httpd-vhosts.conf配置,建议使用第二种方式。首先要开启vhost.conf配置, 打开vhost.conf进行配置 为了使用基于域名的虚拟主机技术,我们需要指定转载 2014-06-23 14:21:59 · 6869 阅读 · 0 评论 -
部分排序算法(php版)
$arr=array(3,6,5,7,1,8,2,9,10,4);print_r($arr);function swap(&$arr,$i,$j){ $tmp=$arr[$i]; $arr[$i]=$arr[$j];$arr[$j]=$tmp;}function quicksort(&$arr,$start,$end){if($start$start && $arr[--$j]-$base>=原创 2014-01-27 14:21:54 · 642 阅读 · 0 评论 -
杨辉三角(php版)
网页标题 <?php//获得总行数$math = isset($_POST['txt'])?$_POST['txt']:0;//控制行号for($i =1;$i<=$math;++$i){ //控制前导空格 for($n=1; $n<=$math-$i; ++$n) { echo " "; } //控制 每行上字转载 2014-06-16 00:44:48 · 1390 阅读 · 0 评论 -
不用第三方变量交换两个int类型的值 php
<?php $a = 4;$b = 1;// way1/*$a = $a ^ $b;$b = $a ^ $b;$a = $a ^ $b;echo $a , $b;*/// way2/*$a = $a + $b;$b = $a - $b;$a = $a -$b;*///way3//list($b,$a) = array($a,$b);//way4/*$b原创 2015-11-26 00:46:18 · 509 阅读 · 0 评论 -
PHP 操作mongodb api大部分方法
<?php$connection = new MongoClient(); // connect$collection = $connection->database->aaa; $doc = array( "name"=>"MongoDB", "type"=>"database", "count"=>1, "info"=>(object)array("x"=>203, "转载 2015-07-20 16:28:17 · 394 阅读 · 0 评论 -
cURL
//1.初始化$ch=curl_init();//2.设置选项,包括URL$url="http://static.cnbetacdn.com/newsimg/2013/1107/70_1383785654.png_w600.png";//"http://www.php.net"curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch,C转载 2013-11-07 11:15:06 · 528 阅读 · 0 评论 -
PHPExcel导入导出excel
保存 import('Org.Util.PHPExcel'); import('Org.Util.PHPExcel.Writer.Excel2007'); import('Org.Util.PHPExcel.IOFactory'); import('Org.Util.UserReply'); $this->object = ne转载 2015-05-07 16:51:27 · 983 阅读 · 0 评论 -
thinkphp在save时区别保存失败和未作更改
$result=$model->save();dump($result);保存失败的时候,$result是bool false未更改时$result是int(0)$result=$model->save();if ($result === FALSE) { echo '保存失败';} elseif($result === 0) { echo '未更改';}http:/转载 2015-03-06 15:12:44 · 4202 阅读 · 1 评论 -
php链表
<?phpclass Node{ private $data; private $next; public function getData(){ return $this->data; } public function setData($data){ $this->data = $data; } public function getNex转载 2014-10-11 18:07:29 · 651 阅读 · 0 评论 -
php 对二维数组的某个键的值进行排序
有时候我们需要对二维数组的某个键的值进行排序,这里就是讨论这个问题。我们可以使用array_multisort()这个函数。array_multisort() 函数对多个数组或多维数组进行排序。参数中的数组被当成一个表的列并以行来进行排序 - 这类似 SQL 的 ORDER BY 子句的功能。第一个数组是要排序的主要数组。数组中的行(值)比较为相同的话,就会按照下一个输入数组中相应值的大小转载 2014-09-17 15:44:51 · 7991 阅读 · 0 评论 -
PHP简单的IoC控制反转实现
fruit.php<?php /** * @author Gonn, http://www.nowamagic.net/ */interface Fruit { public function showColor();}class Apple implements Fruit { private $color; function getColor(){转载 2014-09-17 15:47:09 · 960 阅读 · 0 评论 -
php判断IP地址格式是否正确
1.正则表达式转载 2014-09-03 16:38:33 · 5894 阅读 · 0 评论 -
php xml与数组相互转化
xmlConstruct.class.php<?phpclass xmlConstruct extends XMLWriter{ /** * Constructor. * @param string $prm_rootElementName A root element's name of a current xml document * @param转载 2014-08-18 18:20:15 · 491 阅读 · 0 评论 -
thinkphp入门
框架 framework上传类,分页类,购物车类,数据库类这么多实用的工具类,加在一起,是不是框架呢?答:不是,这些只是工具包(库).框架:是供代码运行的环境.豆浆机,手工洗黄豆(controller,model)豆浆机把controller,model等自动组合起来,产生作用.开发上的好处:1:屏蔽了平台,版本的区别转载 2013-08-04 18:37:33 · 1137 阅读 · 0 评论 -
迭代、递归解决斐波纳挈数列问题
<?php/** * @param $n int 第N项 * * @return int 第N项的值 */function f($n) { //已知条件 $before_1 = 1;//前一项(初始化时就是第二项) $before_2 = 1;//前二项(初始化时就是第一项) //判断是否是第一项或第二项 if($n == 1) { return $before_2转载 2014-06-21 18:40:41 · 1462 阅读 · 0 评论 -
数组指针特例-写时复制cow(copy on write)
<?php$arr1 = array('吕布', '赵云', '典韦');end($arr1);next($arr1);//非法了$arr2 = $arr1;//值传递//使用的一个数组(指针非法的那个数组)//var_dump($arr2);var_dump(current($arr1));echo '';var_dump(current($arr2));$arr2[] =转载 2014-06-21 00:36:52 · 846 阅读 · 0 评论 -
猴子吃枣-杨辉三角-星星塔-公约数
<?phpfunction monkeyEat1($d=1) { //$i第几天 //$n第几天的枣子数 for($i=10, $n=1; $i>=$d; --$i) { echo '第', $i, '天,有', $n, '个枣子'; //修改枣子数量 if($i != $d) { //算前一天的数量 $n = 2*$n+2;//2*($n+1) } }转载 2014-06-21 00:33:17 · 1121 阅读 · 0 评论 -
HTTP协议
<?php//get方式的请求行//GET /test.php HTTP/1.1//post方式的请求行//POST /index.php?p=back&c=Admin&a=signin HTTP/1.1//GET /test.php HTTP/1.1\r\n//Host:shop.100.com\r\n//User-Agent:firefox\r\n//\r\n$host转载 2014-05-12 23:37:02 · 2325 阅读 · 0 评论 -
MVC框架原理
目录结构shop/ 项目的根目录app/ 应用程序目录controller/ 控制器目录front/ 前台控制器admin/ 后台控制器model/ 模型目录模型文件view/ 视图目录front/ 前台视图admin/ 后台视图Framework/ 框架代码目录Model.class.php 基础模型类MySQLDB.class.php 数据库转载 2014-06-24 17:56:40 · 465 阅读 · 0 评论 -
php面向对象单例模式
转载 2013-08-30 00:44:25 · 506 阅读 · 0 评论 -
php多态
类型多态方法多态转载 2013-08-29 21:19:59 · 505 阅读 · 0 评论 -
递归--目录操作及无限级分类之子孙树应用
转载 2013-08-18 20:38:32 · 619 阅读 · 0 评论 -
php面向对象(一)
转载 2013-08-11 23:33:01 · 447 阅读 · 0 评论 -
中文截取无乱码、 顺序查找和二分查找函数
共两种方法,第一种比较全面,第二种方法比较精简(只适合中文和ANSI字符的截取)第一种,比较全面:function utf8SubFix($str,$start,$len){ $strlen=strlen($str); if(!$len||$len echo '参数错误'; return false; } if($转载 2013-08-26 22:40:22 · 812 阅读 · 0 评论 -
php面向对象设计模式
//单例模式(singleton)class Prefences{ private $props=array(); private static $instance; public function __construct(){} public static function getinstance(){ if(empty(self::$instance)转载 2013-08-14 16:20:42 · 619 阅读 · 0 评论 -
php面向对象(二)
MVC抽象类转载 2013-08-20 22:46:34 · 398 阅读 · 0 评论