手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 免费部署 N8N 的 Zeabur 注册 | 登陆
浏览模式: 标准 | 列表分类:PHP

getimagesize

 看到这个标题,你是不是会觉得很无聊?事实上,我是想表达另外的意思。从php5.2开始,很多操作都是支持streamwrapper的功能的,所以当有一个需求:从网上下载一张图片,存到本地,并使用正确的后缀名,就需要用到getimagesize了。

PHP代码
  1. $data = file_get_contents($url);  
  2. file_put_contents('xxx',$data);  
  3. $imageinfo = getimagesize(xxx);  
  4. $extension = func($imageinfo); //获取文件属性  
  5. rename('xxx','xxx.???');  

以前的逻辑可以是这样。但现在可以简化一下

PHP代码
  1. $data  = file_get_contents($url);  
  2. $imageinfo = getimagesize('data:image/;base64,'.base64_encode($data));  
  3. $extension = func($imageinfo); //获取文件属性  
  4. file_put_contents('xxx.'.$extension , $data);  

 

Tags: getimagesize

PHP 飞信类

偷了个懒,代码扔在github上了。
用法也很简单:

    $fetion = new PHPFetion('用户名','密码');     $fetion->send('对方手机','信息');     会自动识别自己还是对方。(非好友不能发哦)

也实现了$fetion->multiSend,但我偷了个懒,直接循环用send发送了。
事实上,可以在刚登录的时候,利用group先将好友列表拉回来,然后就方便了。但觉得这样就复杂了。何必呢。。一般在用飞信的时候,也很少会用到群发功能吧。所以,我还是循环的send。黑黑

代码地址:https://github.com/neatstudio/yiiextension
欢迎围观

Tags: 飞信, fetion

yiibooster+bsie

对于使用yii框架来说,如果使用bootstrap框架的话,现在有一个比较方便的使用途径:yiibooster。
官网地址是:http://yii-booster.clevertech.biz/
当然,我们都知道bootstrap几乎是不支持IE 6的。所以这时候,为了兼容IE6,还得冒出个:BSIE(鄙视IE),官方地址为:https://github.com/ddouble/bsie

有了这两样东西,开发起来是不是快了很多,至少你不用太关心页面是怎么做的了。而且变形,还没有那么夸张。更为可贵的是,你在手机上也能够正常浏览。
比如:http://photo.pinjian.net。就支持了手机浏览,只是界面难看了点罢了

Tags: yiibooster, bsie, yii

转:经典算法

Tags: 算法

php5不再支持2003

看了一下5.5的更新。。原来5.5开始就放弃windows 2003了。那些想在2003上跑应用的人,要哭了
http://www.php.net/manual/en/migration55.new-features.php

Windows XP and 2003 support dropped

Support for Windows XP and 2003 has been dropped. Windows builds of PHP now require Windows Vista or newer.

添加了finally....

finally keyword added

try-catch blocks now support a finally block for code that should be run regardless of whether an exception has been thrown or not.

foreach的时候,可以list了。不需要再$val[0]

foreach now supports list()

The foreach control structure now supports unpacking nested arrays into separate variables via the list() construct. 

 

empty() supports arbitrary expressions

Passing an arbitrary expression instead of a variable to empty() is now supported.

array and string literal dereferencing

Array and string literals can now be dereferenced directly to access individual elements and characters:

PHP代码
  1. <?php  
  2. echo 'Array dereferencing: ';  
  3. echo [1, 2, 3][0];  
  4. echo "\n";  
  5.   
  6. echo 'String dereferencing: ';  
  7. echo 'PHP'[0];  
  8. echo "\n";  
  9. ?>  
还有一个:

New password hashing API

A new password hashing API that makes it easier to securely hash and manage passwords using the same underlying library as crypt() in PHP has been added. See the documentation for password_hash() for more detail.

 

额。难道以后的wordpress也可以直接用这个了?