在不破坏单词的情况下截断字符串/*returns text limited by a specified length of characters but keeping words intact. the final character count will not be exact since it is affected by the poss……继续阅读 » 水墨上仙 5年前 (2021-03-22) 1758浏览 1829个赞
一个简单的php BBCode替换函数function BBcode($texto){ $a = array( "/\[i\](.*?)\[\/i\]/is", "/\[b\](.*?)\[\/b\]/is", "/\[u\](.*?)\[\/u\]/is&qu……继续阅读 » 水墨上仙 5年前 (2021-03-22) 3178浏览 2308个赞
从给定的url中移除指定的参数,如果参数不存在,则返回原urlfunction remove_querystring_var($url, $key) { $url = preg_replace('/(.*)(?|&)' . $key . '=[^&]+?(&)(.*)/i', ……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2800浏览 2937个赞
这段代码可以动态为url添加key-value查询参数,如果参数已经存在则会用新的进行覆盖function add_querystring_var($url, $key, $value) { $url = preg_replace('/(.*)(?|&)' . $key . '=[^&]+?(&am……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2886浏览 415个赞
php修改上传图片的尺寸<?php // This is the temporary file created by PHP$uploadedfile = $_FILES['uploadfile']['tmp_name']; // Create an Image from it so we can……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2823浏览 2188个赞
php验证邮件地址函数<?php function validateEmail($email){ $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { ……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2126浏览 533个赞
php得到当前页面的完整地址function full_url(){ $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $p……继续阅读 » 水墨上仙 5年前 (2021-03-22) 1867浏览 149个赞
一个非常全面的php Email地址函数function check_email_address($email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]……继续阅读 » 水墨上仙 5年前 (2021-03-22) 1747浏览 1229个赞
一段简单的php生成图片水印的代码,这段代码只支持图片水印function watermark($imagesource){ $filetype = substr($imagesource,strlen($imagesource)-4,4); $filetype = strtolower($filetype); if($filetype ==……继续阅读 » 水墨上仙 5年前 (2021-03-22) 3374浏览 739个赞
php给自己发送自动备份的mysql数据表邮件<?// Create the mysql backup file// edit this section$dbhost = "yourhost"; // usually localhost$dbuser = "yourusername";$dbpas……继续阅读 » 水墨上仙 5年前 (2021-03-22) 3119浏览 786个赞
php记录Google机器人访问足迹<?php $email = "test@test.com"; if(eregi("googlebot",$HTTP_USER_AGENT)){ if ($QUERY_STRING != "") { $url ……继续阅读 » 水墨上仙 5年前 (2021-03-22) 1573浏览 761个赞
一段php发送邮件的代码,邮件格式可以使纯文本或者html,可以添加附件PHP: Sending Email (Text/HTML/Attachments) Email is the most popular Internet service today. A plenty of emails are sent and delivered each……继续阅读 » 水墨上仙 5年前 (2021-03-22) 1849浏览 527个赞
通过这段代码可以判断用户的请求是否来自AJAX XMLHttpRequest,以区别普通post,get和ajaxfunction isAjax() {return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUES……继续阅读 » 水墨上仙 5年前 (2021-03-22) 3106浏览 1314个赞
这段php类可以挨个添加文件到数组,最后将添加的文件打包成zip/* $Id: zip.lib.php,v 1.1 2004/02/14 15:21:18 anoncvs_tusedb Exp $ */ // vim: expandtab sw=4 ts=4 sts=4: /** * Zip file creation class. *……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2083浏览 1991个赞
一个简单的正则表达式清理不需要的字符function setDescriptionString($inputString=""){$replacedWords = array("…","‘","ó","<ul>","<li&……继续阅读 » 水墨上仙 5年前 (2021-03-22) 3332浏览 1571个赞
PHP读取远程文件function urlfopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE , $ip = '', $timeout = 15, $block = TRUE, $encodetype =……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2444浏览 2879个赞
php从上传的文件创建缩略图<? if ($_REQUEST['action']=="add"){ $userfile = $HTTP_POST_FILES['photo']['tmp_name']; $userfile_name = $HTTP_POST_FI……继续阅读 » 水墨上仙 5年前 (2021-03-22) 1717浏览 720个赞
这个类可以在网上搜索,使用了Bing搜索API。它可以发送HTTP请求到Bing搜索API的Web服务器执行搜索Web内容使用以前获得的API密钥。类可以搜索网页,图片,视频,新闻和相关的关键字。<? class BingAPI{ var $accountKey = ''; var $ServiceRoo……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2566浏览 2974个赞
php获得网站访问统计信息的类Compete API,Compete是一个专门用来统计网站信息的网站<?php// Check for dependenciesif (!function_exists('curl_init')) throw new Exception('Compete needs the C……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2102浏览 1447个赞
这个seo类的功能包括:– 检查指定的网站响应– 获取从该网站主页的语言和其他meta标签数据的– 获取网站的导入链接,从Alexa的流量排名– 获取网站的导入链接,由谷歌索引的网页数量– 获取网站的信任,从WOT排名。– 获取,因为它是第一个注册的网站域名年龄– 获取的Tw……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2597浏览 1541个赞
在限定的区域里自动调整字体大小的php类 imagefittext.class.php<?php // Image Fit Text Class 0.1 by ming0070913 CLASS ImageFitText{ public $font, $fontsize, $width, $height; public $……继续阅读 » 水墨上仙 5年前 (2021-03-22) 1812浏览 429个赞
php专用数组排序的类 ArraySortUtil** * ArraySortUtil is a array sort utility, you can extends the sorting engine. * * @version 0.1 * @author coderkk Cudnik <coderkk@gmail.com&……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2457浏览 2910个赞
php封装的mongodb操作类<?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ class mongo_db { private $c……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2816浏览 512个赞
php文本url转换为链接function text2links($str='') { if($str=='' or !preg_match('/(http|www\.|@)/i', $str)) { return $str; } $lines = explode(&q……继续阅读 » 水墨上仙 5年前 (2021-03-22) 1892浏览 2536个赞
php获取来源地址function referrer_link() {$refer = $_SERVER['HTTP_REFERER']; if ($refer) { echo '<a href="' . $refer . '">Go back</a>……继续阅读 » 水墨上仙 5年前 (2021-03-22) 3071浏览 2330个赞
php备份你的mysql数据库的代码片段<?phpbackup_tables('localhost','misslily','misslily','blog','*'); /* backup the db OR just a table ……继续阅读 » 水墨上仙 5年前 (2021-03-22) 1985浏览 1403个赞
一个php表单验证的演示代码,如果验证失败会在当前页显示提示信息<?php // Quick function to loop through regexs and compare to what is in _POST// // $regs -> associative array of regular exp……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2348浏览 1305个赞
把字符串中的url替换成可点击的链接,默认给链接添加nofollow,即不允许搜索引擎搜索function replace_urls($string, $rel = 'nofollow'){ $host = "([a-z\d][-a-z\d]*[a-z\d]\.)+[a-z][-a-z\d]*[a-z]"……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2601浏览 1582个赞
php查询数据库后,输出查询结果,隔行变色显示<?php$host="localhost"; // Host name$username=""; // Mysql username$password=""; // Mysql password$db_name="test……继续阅读 » 水墨上仙 5年前 (2021-03-22) 3047浏览 542个赞
php返回文件扩展名//gets a filenames extensionfunction filename_extension($filename) {//{{{ $pos = strrpos($filename, '.'); if($pos===false) { return false; }……继续阅读 » 水墨上仙 5年前 (2021-03-22) 3971浏览 2353个赞
一个完全面向对象的RSS/XML php类<?phperror_reporting(E_ALL); mysql_connect("localhost","root","root") or die (mysql_error());mysql_select_db("oop&……继续阅读 » 水墨上仙 5年前 (2021-03-22) 3012浏览 1720个赞
php生成圆角图片代码<?php$image_file = $_GET['src'];$corner_radius = isset($_GET['radius']) ? $_GET['radius'] : 20; // The default corner radius is set……继续阅读 » 水墨上仙 5年前 (2021-03-22) 1431浏览 2160个赞
一个超简单的php 许可系统代码<?php $fp = fopen("http://domain.com/lic.txt", "r");stream_set_timeout($fp, 10);$license = fread($fp, filesize($filename));fclose($fp……继续阅读 » 水墨上仙 5年前 (2021-03-22) 3363浏览 1523个赞
php返回图片属性list($width, $height, $type, $atrib) = getimagesize($path.$image);……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2446浏览 0评论2909个赞
调用方法:此代码可以为大图片动态生成缩略图显示,图片在内存中生成,不在硬盘生成真实文件<?php /*File: thumbs.phpExample: <img src="thumbs.php?filename=photo.jpg&width=100&height=100">*/ $f……继续阅读 » 水墨上仙 5年前 (2021-03-22) 1592浏览 0评论2460个赞
C语言求1000以内的完美数完全数(Perfect number),又称完美数或完备数,是一些特殊的自然数。它所有的真因子(即除了自身以外的约数)的和(即因子函数),恰好等于它本身。#include "stdio.h"void main(){int sum,k,j;for(k=2;k<=1000;k++){sum=0……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2053浏览 265个赞
C语言计算2个字符串的编辑距离编辑距离:通过插入、删除、替换一个字符(和交换相邻字符)的操作,使得字符串A和字符串B相同,而最少的操作次数就是编辑距离。如字符串abcd和aca的距离是2代码转自:http://blog.csdn.net/wapwo/article/details/8831810 ……继续阅读 » 水墨上仙 5年前 (2021-03-22) 1919浏览 2823个赞
C语言进行回文检测回文:称正读和反读都相同的字符序列为“回文”,如“abba”、“abccba”、12321、123321是“回文”,“abcde”和“ababab”则不是“回文”。#include<stdio.h>#include<string.h>int main(void){ char str[100]; in……继续阅读 » 水墨上仙 5年前 (2021-03-22) 1835浏览 2530个赞
C语言判断给定的数是否是回文数回文数是指一个像16461这样“对称”的数,即:将这个数的数字按相反的顺序重新排列后,所得到的数和原来的数一样。bool isPalindrome(int num){ int pal = 0; int origin = num; while(num) { pal *= 1……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2682浏览 2416个赞
c语言猴子选大王(约瑟夫环问题)#include #include #define n 20#define m 5typedef struct monkey{ int num; struct monkey *next;} Monkey,*LINK;int main(){ LINK p,head,p2; int i; ……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2165浏览 971个赞
题目描述: n个人围坐一圈,标号1-n,从s开始报数,第m个报的人出列,一直循环下去直到所有人出列。设计一算法,输入n,m,s,输出出列顺序。这个问题有好多种算法,我是用双向循环链表实现的转自:http://blog.csdn.net/shiyanhui66/article/details/5991752/* *use two-directi……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2131浏览 1352个赞
c语言实现两种查找的示例#include <stdio.h>#include <stdlib.h>int main(){ int L[11]={0,70,38,65,97,76,93,1,15,68,64}; //无序序列 int S[11]={0,10,20,30,35,40,65,67,69,84,……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2059浏览 2346个赞
使用C语言清空特定文件夹中的所有文件#include "iostream.h" //由于该博客系统发布是不能显示正常,……继续阅读 » 水墨上仙 5年前 (2021-03-22) 3115浏览 893个赞
C语言 打印一个用字符表示的菱形或正(倒)三角形#include<stdio.h>#include<stdlib.h>main(){ int n,i,k,j; char ch; //n是行数,ch代表所要输出的字符 printf("输入所要打印的行数n和字符ch\n"); sca……继续阅读 » 水墨上仙 5年前 (2021-03-22) 2470浏览 1823个赞
LINUX下c语言SOCKET客户端示范#include <netinet/in.h> // for sockaddr_in#include <sys/types.h> // for socket#include <sys/socket.h> // for socket#include <……继续阅读 » 水墨上仙 5年前 (2021-03-22) 3407浏览 655个赞