
small_program
ypb455360299
这个作者很懒,什么都没留下…
展开
-
简单的socket通讯
服务端代码: <?php set_time_limit(0); $commonProtocol=getprotobyname('tcp'); $sock=socket_create(AF_INET,SOCK_STREAM,$commonProtocol); if($sock){print 'suess!';} $bnd=socket_bind($sock,"127.0.原创 2012-05-08 16:07:08 · 379 阅读 · 0 评论 -
php utf-8字符集下实现中文无乱码截取
1.utf-8下中文字符长度为3,如:echo strlen(‘中’),输出为3; 代码为如下: /** *$string 为要截取的中文或英文混合字符 *length为要截取的长度 */ function utf_string($string,$length){ $str=' '; if(strlen($string)>$le原创 2012-03-28 11:06:14 · 796 阅读 · 0 评论 -
003——一次读入一行文件
文件1.txt 内容分为三行 123@qq.com,5468@qq.com dfj@qq.com efu@qq.com 代码示例: <?php $fh=fopen('1.txt','r'); for($line=fgets($fh);!feof($fh);$line=fgets($fh)){ $line=trim($line); $info=explode(',',$l原创 2012-05-25 00:14:38 · 453 阅读 · 0 评论 -
004——生成验证码
代码如下: <?php $im=imagecreate(45,18);//创建一个45*18的图像 $gray=imagecolorallocate($im,200,200,200);//创建用在image所代表的图像中颜色 for($i=0;$i<4;$i++){ $size=mt_rand(3,6);//字体大小 $x=(5+$i*10);//x轴坐标 $原创 2012-05-26 17:33:14 · 478 阅读 · 0 评论 -
jquery ajax
function Columns(n){ var type; type=$("#perent_"+n).val(); $.ajax({ type:"POST", url:"{{path('columns_ajax')}}", dat原创 2012-07-31 13:19:08 · 457 阅读 · 0 评论 -
获取用户ip
public function getIp(){ //浏览当前页面的用户计算机的网关 if(@$_SERVER["HTTP_X_FORWARDED_FOR"]){ $ip = $_SERVER["HTTP_X_FORWARED_FOR"]; }else if(@$_SERVER["HTTP_CLIENT_IP"]){原创 2013-03-12 23:04:02 · 712 阅读 · 0 评论 -
下载文件
public function downLoadAction(){ $request = $this->getRequest(); $filePath = $request->get('filePath'); header('Content-Type:application/octet-stream'); header('Conten原创 2013-03-17 22:19:39 · 602 阅读 · 0 评论