PHP
共 25 篇文章
mysql_query()防止掉链的数据库查询
// ------------------------------------------------------------------- // 函数名称:自定义 mysql_query (加入防掉链功能) // 调用方式:mysql_query_plus($sql_str, $conn_resource, $dbname_str) // 变量说明:$sql_str - 需要执行的查询语句 [string] // $conn_resource - 数据库连接资源 [resource] // $host=LOCAL_DB_HOST 数据库主机地址,默认为本机配置 // $user=LOCAL…
2011-03-24 14:00 · PHP
Windows下的Memcache安装
转自: http://www.ccvita.com/258.html linux: http://code.google.com/p/memcached/downloads/list http://splinedancer.com/memcached-win32/ xmemcached: http://code.google.com/p/xmemcached/downloads/list PHP 库可从这里下载: http://downloads.php.net/pierre/ php_memcache-2.2.6-5.3-nts-vc9-x86.zip (2010-10-03 13:46 …
2011-03-22 10:06 · PHP
PHP 解决采集乱码问题mb_convert_encoding和iconv使用比较
转自: http://hi.baidu.com/cubeking/blog/item/f85277fc155f173d5d600855.html mb_convert_encoding的用法见官方: http://cn.php.net/manual/zh/function.mb-convert-encoding.php 做一个GBK To UTF-8 < ?php header("content-Type: text/html; charset=Utf-8"); echo mb_convert_encoding("妳係我的友仔", "UTF-8", "GBK"); ?> 再来个GB2312 …
2011-02-11 13:27 · PHP
采集数据
<? // 连接数据库的配置 $config = array( 'url' => LOCAL_DB_HOST.':3306', 'user' => LOCAL_DB_USER, 'password' => LOCAL_DB_PWD, 'db' => LOCAL_DB_NAME, ); $is_debug = true; // 命令行参数一为日志的开关 $log = new CommonLog(array('log_level' => $_SERVER["argv"][1],)); // 连接数据库实例 $db = new DBConfig($config); $today = date('Y…
2011-01-28 17:27 · PHP
eclipse xdebug 配置手册
XDebug Support In PDT 1.0 : http://www.eclipse.org/pdt/documents/XDebugGuide.pdf XDebug Support In PDT 2.0 : http://www.eclipse.org/pdt/documents/XDebugGuideForPDT2.0.pdf Debugging PHP using Eclipse and PDT : http://www.eclipse.org/pdt/articles/debugger/os-php-eclipse-pdt-debug-pdf.pdf XDebug Docum…
2010-10-22 14:12 · PHP
file_get_contents的超时处理
转自: http://www.neatstudio.com/show-1285-1.shtml PHP 技巧:file_get_contents的超时处理 首页 > PHP > Submitted by gouki on 2010, May 17, 3:34 PM. PHP 收藏到QQ书签分享至微博 话说,从PHP5开始,file_get_content已经支持 context了(手册上写着:5.0.0 Added the context support. ),也就是说,从5.0开始,file_get_contents其实也可以POST数据,关于这个,我在通过file_get_content…
2010-08-17 14:57 · PHP
在php 5.2版本之前使用的json_encode和json_decode函数
http://mike.teczno.com/JSON/JSON.phps 某php页面的的代码。 $json = new Services_JSON(); echo $json->encode( $this );
2010-08-13 09:33 · PHP
月份处理函数
function period_diff($in_dateLow, $in_dateHigh) { if ($in_dateLow > $in_dateHigh) { $tmp = $in_dateLow; $in_dateLow = $in_dateHigh; $in_dateHigh = $tmp; } $dateLow = $in_dateLow; $dateHigh = strftime('%m/%Y', $in_dateHigh); $periodDiff = 0; while (strftime('%m/%Y', $dateLow) != $dateHigh) { $period…
2010-08-11 22:00 · PHP
配置xdebug
zend_extension = "D:/xampp/php/ext/php_xdebug.dll" [Xdebug] xdebug.profiler_enable=On xdebug.trace_output_dir="D:/xampp/apache/logs" xdebug.profiler_output_dir="D:/xampp/apache/logs" xdebug.remote_enable= On xdebug.remote_handler= dbgp xdebug.remote_host= localhost xdebug.remote_port= 9000 ;开启自动跟踪 …
2010-08-10 09:19 · PHP
判断在linux以命令行执行的文件是否还在执行
// 取得当前程序进程,用来判断是否可以执行 $gather_in_pro = shell_exec('ps -ef | grep "' . basename(__FILE__) . '"|grep -v grep | awk \'{print $2}\''); // 判断进程中有几个本程序,如果只有一个说明是本程序的主程序, // 如果超过一个则说明仍有本程序的子进程在运行 // 计划任务执行时会产生两个进程: // /bin/sh -c php your_phpfile.php // php your_phpfile.php // 所以判断条件(当前程序进程数)应大于 2 if (cou…
2010-06-03 10:37 · PHP
PHP分页
<?php header("content-type:text/html;charset=utf-8"); /* * 分页功能 * */ function cut_pages($url_prefix = "", $total_records = 0, $record_per_page = 20, $pages_length = 7, $pages_ul_style = "list-style:none;width:410px;margin:auto; ", $page_li_style = "float:left;font-size:12px; background:white; margi…
2010-05-05 07:15 · PHP
How to implement COMET with PHP
http://www.zeitoun.net/articles/comet_and_php/start Comet is a programming technique that enables web servers to send data to the client without having any need for the client to request it. This technique will produce more responsive applications than classic AJAX. In classic AJAX applications, we…
2009-12-07 13:17 · PHP
PHP 压缩网站上的文件,并返回下载
<?php $zipFileName = "teacher.zip"; $modpath=__FILE__; require_once ("ziparchive/archive.php"); $archive = new zip_file ( $zipFileName ); $archive->set_options ( array ('basedir' => dirname ($modpath ), 'inmemory' => 0, //不在内存压缩.而是直接存放到磁盘.如果要压缩下载,则可以选择为1 'recurse' => 1, //是否压缩子目录,resurse,递归的意思? 'st…
2009-08-27 20:51 · PHP
递归删除目录及目录中的文件
<?php /** * 递归删除目录及目录中的文件 * * @param string $dirName 目录路径 * @return boolean 删除成功返回true,反之false */ function removeDir($dirName) { $result = false; if (! is_dir ( $dirName )) { trigger_error ( "目录名称错误", E_USER_ERROR ); } $handle = opendir ( $dirName ); while ( ($file = readdir ( $handle )) !== false …
2009-08-27 20:24 · PHP
PHP验证码程序:session生成图片
昨天捣鼓了一下PHP验证码并生成图片程序,采用了session识别,稍微改进了一下目前网络上流传的PHP验证码,加入杂点,数字颜色随机显示,控制4位数字显示;话不多说了,程序如下,分享出来。 效果图如下: 新建yz.php验证码生成文件: 注意:以下代码需要打开php的GD库,修改php.in文件的配置,把已经注释掉的行之前的分号取消即可:extension=php_gd2.dll。 <? session_start(); //生成验证码图片 Header("Content-type: image/PNG"); $im = imagecreate(44,18); $back = ImageC…
2009-08-07 15:39 · PHP
Apache的rewrite规则详细介绍
rewrite标志 R [=code](force redirect) 强制外部重定向 强制在替代字符串加上http://thishost[:thisport]/前缀重定向到外部的URL.如果code不指定,将用缺省的302 HTTP状态码。 F (force URL to be forbidden)禁用URL,返回403HTTP状态码。 G (force URL to be gone) 强制URL为GONE,返回410HTTP状态码。 P (force proxy) 强制使用代理转发。 L (last rule) 表明当前规则是最后一条规则,停止分析以后规则的重写。 N (next rou…
2009-06-01 22:52 · PHP
php mail 支持UTF-8,附件
<?php class mime_mail { var $parts; var $to; var $from; var $headers; var $subject; var $body; // function mime_mail() { $this->parts = array (); $this->to = ""; $this->from = ""; $this->subject = ""; $this->body = ""; $this->headers = ""; } // function add_attachment($message, $name = "", $ctype =…
2009-03-06 14:19 · PHP
php 多语言切换
目录结构: //============================================ 文件内容: /include/language.php <?php $languages = array (); $languages ['zh-cn'] ["name"] = "china"; $languages ["zh-cn"] ["image"] = "flag1.jpg"; $languages ["en"] ["name"] = "english"; $languages ["en"] ["image"] = "flag2.jpg"; class Language { pu…
2009-02-27 09:55 · PHP