一组php编写的用于金融计算的函数<?php /* VARIABLES: $m = number of periods per year. For instance, if you are For instance, if you are making payments monthly the……继续阅读 » 5年前 (2021-03-22) 2238浏览 1688个赞
php递归遍历多维数组<? # A recursive function to traverse a multi-dimensional array # where the dimensions are not known # function get_array_elems($arrResult, $where="ar……继续阅读 » 5年前 (2021-03-22) 2673浏览 1817个赞
php不透露实际地址的文件下载function download_document($filename, $path = "", $mimetype = "application/octet-stream"){ header("Cache-Control: must-revalidate, post……继续阅读 » 5年前 (2021-03-22) 1723浏览 505个赞
这段代码用于提供下载,不是用来下载别人网站的内容的<?php $filename = $_GET['filename']; // Modify this line to indicate the location of the files you want people to be able to download/……继续阅读 » 5年前 (2021-03-22) 3159浏览 2142个赞
php获得一个mysql数据查询结果if (!function_exists('mysql_fetch_results')) { function mysql_fetch_results($resource, $results = Array()) { while($row = @mysql_fetch_a……继续阅读 » 5年前 (2021-03-22) 1665浏览 825个赞
php列出mysql指定数据库中的所有表if (!function_exists('mysql_list_db_tables')) { function mysql_list_db_tables($database) { $tables = Array(); $results = mysql……继续阅读 » 5年前 (2021-03-22) 2321浏览 2498个赞
php列出mysql中可用数据库的名字if (!function_exists('mysql_list_databases')) { function mysql_list_databases($resources = Array()) { $list = Array(); for ($i ……继续阅读 » 5年前 (2021-03-22) 1367浏览 2192个赞
php读取数据库生成一条一条的sql语句,可以用作mysql的备份if (!function_exists('mysql_dump')) { function mysql_dump($database) { $query = ''; $tables = @mysql_li……继续阅读 » 5年前 (2021-03-22) 2909浏览 2087个赞
php5已经包含了file_pub_contents函数,这个可以用在php4中if (!function_exists('file_put_contents')) { function file_put_contents($file, $contents = '', $method = 'a……继续阅读 » 5年前 (2021-03-22) 2755浏览 1697个赞
php正则表达式验证邮件地址$string = "first.last@domain.co.uk"; if (preg_match('/^[^\W][a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\@[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/'……继续阅读 » 5年前 (2021-03-22) 1651浏览 1459个赞
这段代码演示了php中如果打包文件为zip格式function create_zip($files = array(),$destination = '',$overwrite = false) { //if the zip file already exists and overwrite is false, return fa……继续阅读 » 5年前 (2021-03-22) 1362浏览 774个赞
php到处mysql数据到excel文件<?php // DB TABLE Exporter//// How to use://// Place this file in a safe place, edit the info just below here// browse to the file, enjoy! // CHA……继续阅读 » 5年前 (2021-03-22) 2632浏览 2064个赞
这段代码演示了php中如何发送html格式的邮件/*EXAMPLE: htmlmail('user@domain.com', 'Look ma, HTML e-mails','You just got <a href="http://www.yougotrickrolled.com/&……继续阅读 » 5年前 (2021-03-22) 2805浏览 2857个赞
这段代码通过各种手段来检测用户终端是否是移动设备function mobile_device_detect($iphone=true,$ipad=true,$android=true,$opera=true,$blackberry=true,$palm=true,$windows=true,$mobileredirect=false,$desktopr……继续阅读 » 5年前 (2021-03-22) 2298浏览 1866个赞
php在当前页验证表单数据URL: http://support.jodohost.com/showthread.php?t=4350<?php function VerifyForm(&$values, &$errors){ // Do all necessary form verification i……继续阅读 » 5年前 (2021-03-22) 3072浏览 266个赞
这个php图片上传类功能非常完善,完全可以满足各种图片上传需求<?php/************************************** seesaw associates | http://seesaw.net client: file: description: Copyright (C) 2008 M……继续阅读 » 5年前 (2021-03-22) 2788浏览 2122个赞
这段代码可以检测用户是否使用移动设备浏览网页,检验非常完整<?php $mobile_browser = '0'; if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone)/i', strtolowe……继续阅读 » 5年前 (2021-03-22) 2756浏览 2734个赞
这段代码简单的演示了php如何读取和分析xml文件//xml.xml : <?xml version="1.0" encoding="utf-8" ?><Kategorien> <Kategorie> <ID>1</ID> ……继续阅读 » 5年前 (2021-03-22) 1649浏览 1119个赞
php检测给定的url地址是否存在function url_exists($url) { $hdrs = @get_headers($url); return is_array($hdrs) ? preg_match('/^HTTP\\/\\d+\\.\\d+\\s+2\\d\\d\\s+.*$/',$hdrs[0]……继续阅读 » 5年前 (2021-03-22) 1958浏览 682个赞
php中通过定义mysql_safe_string函数防止sql注入function mysql_safe_string($value) { if(empty($value)) return 'NULL'; elseif(is_string($value)) return '\……继续阅读 » 5年前 (2021-03-22) 1390浏览 505个赞
这段代码提供了几个常用的正则//replace all but links/<(?!\/?a(?=>|\s.*>))\/?.*?>/g //validate url/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \?=.-]*)*\/?$/ //Validate……继续阅读 » 5年前 (2021-03-22) 1385浏览 2249个赞
php链接mysql的基本方法$username="username";$password="password";$database="your_database";$table="your_table"; mysql_connect(localhost,$use……继续阅读 » 5年前 (2021-03-22) 1934浏览 801个赞
面向对象的mysql数据库操作php类<?phpclass database { var $host = NULL; var $username = NULL; var $password = NULL; var $databaseName = NULL; var $link = NULL; var $queries = NUL……继续阅读 » 5年前 (2021-03-22) 3105浏览 2888个赞
php获取twitter最新的消息<?phpfunction get_status($twitter_id, $hyperlinks = true) { $c = curl_init(); curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_ti……继续阅读 » 5年前 (2021-03-22) 1557浏览 2877个赞
一个php mysql数据库操作类,功能不是很完善,但非常有用<?phpclass Database{ private $host; private $user; private $pwd; private $rows; private $error; private $result; private $dbName; pri……继续阅读 » 5年前 (2021-03-22) 2355浏览 389个赞
这段代码比较完整,带session写入,mysql数据库查询//escape data and strip tagsfunction safestrip($string){ $string = strip_tags($string); $string = mysql_real_escape_string($string); return $st……继续阅读 » 5年前 (2021-03-22) 2586浏览 2797个赞
一个用来遍历CSV文件的php类<?php class CSVIterator implements Iterator{ const ROW_SIZE = 4096; private $filePointer; private $currentElement; private $rowCounter; private $del……继续阅读 » 5年前 (2021-03-22) 1308浏览 1081个赞
php发送邮件函数,支持html和普通文本<?phpfunction send_mail($emailaddress, $fromaddress, $namefrom, $emailsubject, $body){ $eol="\n"; $mime_boundary=md5(time()); # Commo……继续阅读 » 5年前 (2021-03-22) 2423浏览 880个赞
php返回相对时间,如:20分钟前,3天前function plural($num) { if ($num != 1) return "s";} function getRelativeTime($date) { $diff = time() - strtotime($date); if ($diff<60)……继续阅读 » 5年前 (2021-03-22) 2987浏览 676个赞
php优化mysql数据库的所有表<?php dbConnect(); // Database connection $alltables = mysql_query("SHOW TABLES"); while ($table = mysql_fetch_assoc($alltables)) { for……继续阅读 » 5年前 (2021-03-22) 1723浏览 2236个赞
php计算到指定的日期还有多少天function countdays($d){ $olddate = substr($d, 4); $newdate = date(Y) ."".$olddate; $nextyear = date(Y)+1 ."".$olddate; if($newdate……继续阅读 » 5年前 (2021-03-22) 2229浏览 1480个赞
这段php代码改变了图片直接打开为下载// The php (process.php) $file = $_GET['file'];header ("Content-type: octet/stream");header ("Content-disposition: attachment; fi……继续阅读 » 5年前 (2021-03-22) 2027浏览 2017个赞
在不破坏单词的情况下截断字符串/*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) 3110浏览 357个赞
一个简单的php BBCode替换函数function BBcode($texto){ $a = array( "/\[i\](.*?)\[\/i\]/is", "/\[b\](.*?)\[\/b\]/is", "/\[u\](.*?)\[\/u\]/is&qu……继续阅读 » 5年前 (2021-03-22) 2134浏览 1635个赞
从给定的url中移除指定的参数,如果参数不存在,则返回原urlfunction remove_querystring_var($url, $key) { $url = preg_replace('/(.*)(?|&)' . $key . '=[^&]+?(&)(.*)/i', ……继续阅读 » 5年前 (2021-03-22) 1780浏览 1365个赞
这段代码可以动态为url添加key-value查询参数,如果参数已经存在则会用新的进行覆盖function add_querystring_var($url, $key, $value) { $url = preg_replace('/(.*)(?|&)' . $key . '=[^&]+?(&am……继续阅读 » 5年前 (2021-03-22) 3229浏览 2350个赞
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) 1362浏览 1767个赞
php验证邮件地址函数<?php function validateEmail($email){ $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { ……继续阅读 » 5年前 (2021-03-22) 1791浏览 926个赞
php得到当前页面的完整地址function full_url(){ $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $p……继续阅读 » 5年前 (2021-03-22) 2897浏览 2737个赞
一个非常全面的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) 2517浏览 1240个赞
一段简单的php生成图片水印的代码,这段代码只支持图片水印function watermark($imagesource){ $filetype = substr($imagesource,strlen($imagesource)-4,4); $filetype = strtolower($filetype); if($filetype ==……继续阅读 » 5年前 (2021-03-22) 2791浏览 2748个赞
php给自己发送自动备份的mysql数据表邮件<?// Create the mysql backup file// edit this section$dbhost = "yourhost"; // usually localhost$dbuser = "yourusername";$dbpas……继续阅读 » 5年前 (2021-03-22) 2330浏览 2631个赞
php记录Google机器人访问足迹<?php $email = "test@test.com"; if(eregi("googlebot",$HTTP_USER_AGENT)){ if ($QUERY_STRING != "") { $url ……继续阅读 » 5年前 (2021-03-22) 1771浏览 1802个赞
一段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) 2870浏览 968个赞
通过这段代码可以判断用户的请求是否来自AJAX XMLHttpRequest,以区别普通post,get和ajaxfunction isAjax() {return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUES……继续阅读 » 5年前 (2021-03-22) 3456浏览 2468个赞