php随机字符生成代码,可以指定长度<?php # This particular code will generate a random string # that is 25 charicters long 25 comes from the number # that is in the for loop $string = &qu……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1824浏览 0评论2950个赞
php剪切图片并给图片打上水印的代码此程序转自www.enterdesk.com回车桌面网络图片处理程序$wh=getimagesize($filename);$w=$wh[0];$h=$wh[1];$fenbianlv=$_REQUEST['tfbl'];if(preg_match("~(\d+)x(\d+)~&……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3197浏览 0评论995个赞
一个标准的php链接mysql数据库的代码,并提供简单的查询范例<?php //create db connection $connection = mysql_connect("localhost", "user", "password"); if(!$connection) ……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1446浏览 0评论1872个赞
一个简单的php校验邮箱的代码<?php if(isset($_POST['email'])){ $email = $_POST['email']; if(filter_var($email, FILTER_VALIDATE_EMAIL)){ echo '&……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3020浏览 0评论2821个赞
php从N个数中找出最大的10个数代码题目:从N个数中选取最大的前10个, 有序输出.N最大可能达到1000亿每个数范围是0 – 2147483647author: goosman.leimail: lgg860911@yahoo.com.cnblog: ……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2311浏览 0评论1687个赞
php转换jpg图片为ASCII码<html> <head> <title>Ascii</title> <style> body{ line-height:1px; font-size:1px; } </style> </h……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2502浏览 0评论2815个赞
给数字后面添加 “th, st, nd, rd, th” 等符号. 例如: 10 to 10th.<?php function ordinal($cdnl){ $test_c = abs($cdnl) % 10; $ext = ((abs($cdnl) %100 < 21 && ……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1809浏览 0评论908个赞
php读取,编辑和保存文件代码save_file.php<?php session_start(); $handle = fopen($_POST['original_file_name'], "w"); $text = $_POST['file_contents']; if……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1653浏览 0评论2065个赞
This new updated ASCII converter supports alpha channels, so for this code to work you need a browser that supports CSS3 Aplah Channels. Convert any GD supported image into ASCII a……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2911浏览 0评论148个赞
本代码演示了如果不通过表单把信息直接提交到post信息里,非常有用form.html<form action="show.php" method="post"> Enter Your Name: <input type="text" name="myNam……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3492浏览 0评论813个赞
php统计字符串单词数量<?php function word_count($sentence){ $array = explode(" ", $sentence); return count($array); } $words = word_count(&qu……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2031浏览 0评论2952个赞
英尺,英里,和英寸转换器php代码<?php function distance($curlen,$type,$totype,$on){ //Check to see if the first value is an interger if(!is_int($curlen)){ return 'W……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3335浏览 0评论1831个赞
本代码演示了如果通过用户正在访问的页面获取用户的ip地址,第一段代码直接获得用户的ip地址,第二段代码可以穿过代理服务器获得用户的真实ip地址?php/* Source: http://www.apphp.com/index.php?snippet=php-get-remote-ip-address */function getRemoteIPAd……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2616浏览 0评论1583个赞
php从指定的目录随机读取文件的函数,参数可以设定文件过滤function RandomFile($folder='', $extensions='.*'){ // fix path: $folder = trim($folder); $folder = ($folder == ……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3085浏览 0评论108个赞
本代码演示了php中如果通过Snoopy抓取网页信息snoopy类的下载地址:http://sourceforge.net/projects/snoopy//*You need the snoopy.class.php from http://snoopy.sourceforge.net/*/ include("snoopy.cla……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2121浏览 0评论331个赞
php调用随机函数生成随机颜色的方法<?php function randColor(){ $letters = "1234567890ABCDEF"; for($i=1;$i<6;$i++){ $pos = rand(0,16); ……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2816浏览 0评论2999个赞
php实现的简单登陆程序,带html代码和登录验证程序html代码:<form action="verify.php" method="post"> User Name:<br> <input type="text" name="use……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2484浏览 0评论101个赞
美国的州简写和标题对应数组,例如 AK 转换成Alaska<?php $state_list = array( 'AL'=>"Alabama", 'AK'=>"Alaska", 'AZ'=>&q……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2333浏览 0评论2786个赞
一个简单的php之分页类代码转自:http://blog.csdn.net/jek803/article/details/8438479/*思路1.把地址栏的URL获取2.分析URL中的query部分--就是?后面传参数的部分3.query部分分析成数组4.把数组中的page单元,+1,-1,形成2个新的数组5.再把新数组拼接成query部……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2160浏览 0评论2348个赞
想知道你是哪个星座的吗,这段代码只需要你输入生日,即可显示所在星座<?php function zodiac($DOB){ $DOB = date("m-d", strtotime($DOB)); list($month,$day) = explode("-",$DOB); ……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3003浏览 0评论1930个赞
项目中经常会用到年份选择,这段代码自动生成从今年开始的过去100年的下拉列表<select name="year"><?php $years = range(date("Y"), date("Y", strtotime("now - 100 years"……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1656浏览 0评论282个赞
这段代码计算两个字符串的长度,然后计算其差值<?php // This will return a number of how many more characters the longest string has function str_compare_length($str1, $str2){ $len1 = strlen($……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2181浏览 0评论551个赞
php实现的一个税率计算函数<?php function tax($total,$tax_amount){ $tax_rate = $tax_amount * .01; $tax = $total * $tax_rate; return $value = $tax + $total; } $price = 50……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2878浏览 0评论2850个赞
php5连接Sql Server的两种方法演示代码 1.Com链接,ADODB.Connection $conn = new Com("ADODB.Connection"); //实例化一个Connection对象 $connstr = &q……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2520浏览 0评论1793个赞
php把数组的值转换成键Converts the values of an array to the keys of it.function values2keys($arr, $value=1){ $new = array(); while (list($k,$v) = each($arr)){ $v = trim($……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2912浏览 0评论2605个赞
本代码演示了php中如何使用array_work格式化数组// the test array $array = array( 'php', 'arrays', 'are', 'cool' ); // some variable for testing:……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2677浏览 0评论1211个赞
在php计算字符串相似度similar_text与相似度levenshtein函数的详细介绍 similar_text — 计算两个字符串的相似度 int similar_text (&……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1662浏览 0评论1279个赞
php利用数组实现无限极类别层次/*** 创建父节点树形数组* 参数* $ar 数组,邻接列表方式组织的数据* $id 数组中作为主键的下标或关联键名* $pid 数组中作为父键的下标或关联键名* 返回 多维数组**/function find_parent($ar, $id='id', $pid='pid……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3030浏览 0评论1818个赞
简单的条件判断语句练习,判断两个字符串是否完全一样<?php function strcomp($str1,$str2){ if($str1 == $str2){ return TRUE; }else{ return FALSE; } } echo strcomp("……继续阅读 » 水墨上仙 6年前 (2021-01-15) 5742浏览 0评论2546个赞
本代码演示了php如何连接到mysql数据库<?php if(basename(__FILE__) == basename($_SERVER['PHP_SELF'])) send_404(); $dbHost = "localhost"; //Location Of Database us……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1845浏览 0评论2801个赞
本代码演示了php中如果通过cookie存储用户的选择,更换皮肤样式表saveStyleSheet.php<?php function styleSheet($currentCookie){ # Get Current Style Sheet $currentCookie = $_COOKIE["StyleShe……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3488浏览 0评论153个赞
php控制下载速度// local file that should be send to the client$local_file = 'test-file.zip';// filename that the user gets as default$download_file = 'your-download-……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2705浏览 0评论1715个赞
PHP读取sphinx实例转自:http://yzswyl.cn/blread-1611.html 1.未采用mysql二进制网络协议的代码://检查sphinx是否能连接,不能重试两次,能则连接,不用mysql协议,仅供参考function checkSphinxNoMysql……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3204浏览 0评论927个赞
C语言对字符串进行转义excape操作/** *@brief 对于url中的一些特殊字符会被转义以利传输, * 并且, 归档服务器上, php写入cookie中的值可能存在特殊字符, 需要转换 * *参考: http://www.blooberry.com/indexdot/html/topics/urlencodi……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1506浏览 0评论661个赞
php统计多维数组元素个数$numb=array( array(10,15,30),array(10,15,30),array(10,15,30)); echo count($numb,1); 输出结果为:12count函数中如果mode被设置为&……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3265浏览 0评论1227个赞
一段简单的php代码抓取百度热词/*** 获取百度热词* @author tarylei* @ encoding GBK* @link weibo.com/4699640* @ from http://top.baidu.com/rss_xml.php?p=top10* @ return array 返回百度24小时内热词*/funct……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2288浏览 0评论262个赞
Android通过HttpClient执行Http Post请求public void postData() { // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); HttpPost httppo……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3343浏览 0评论1385个赞
简单的php socket 客户端/服务器端编程 客户端代码<?php error_reporting(E_ALL); set_time_limit(0); echo "<h2>TCP/IP Connection</h2>\n"……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2961浏览 0评论1478个赞
php调用KyotoTycoon测试代码<?phprequire_once 'Net/KyotoTycoon.php';use Net\KyotoTycoon;$cacheManager = new KyotoTycoon(array( 'host' => 'localhost……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1893浏览 0评论359个赞
简单的php上传文件并入库的代码片段<?php/******************************************************************************参数说明:$max_file_size : 上传文件大小限制, 单位BYTE$destination_folder : 上传文件路径……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1483浏览 0评论1578个赞
php支持中文的正则表达式识别链接URL 下面是用php的preg_match的正则表达式:/((?:https?|mailto).*?)( |<br|\'|\"|$)/注意:因为要支持中文连接(例如:http://hi.baidu.com/wuxic……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3306浏览 0评论1242个赞
php调用memcached 的测试代码<?php$cacheServer = new Memcached();$cacheServer->addServer('localhost', 11211);$cacheServer->set('foo', 'bar');$v……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3474浏览 0评论647个赞
php使用glob查找文件<?php$files = glob('/DWH/backup/BOB/*.{zip}',GLOB_BRACE);foreach ($files as $file) { $file = basename($file); echo $file.PHP_EOL;……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2957浏览 0评论1908个赞
这段代码非常有用,如果你下载了一个文件,网站提供了hash结果,你可以对你下载下来的文件进行hash运算,以验证下载的文件是否正确。<html><head> <title>Hash (Check) Files</title> <style type='text/css……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2500浏览 0评论247个赞
PHP简单实现多进程并行处理,子进程负责处理事物,父进程可控制子进程数量,用pcntl扩展实现(备注:在windows下此效果无法实现)/** * $func为子进程执行具体事物的函数名称 * $opt为$func的参数 数组形式 * $pNum 为fork的子进程数量 */function ProcessOpera($func, $opts……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1950浏览 0评论1557个赞