Use the PHPExcel Library
Introduce the PHPExcel library before use
/**
* Excel writing, based on the PHPExcel Library
* @ Param array $ data
* @ Param $ file
* @ Return bool
* @ Throws PHPExcel_Exception
A php class for conversion from the Gregorian calendar to the lunar calendar
// A class for converting the solar calendar to the lunar calendar in PHP
Class Calendar
{
# Number of days of the lunar calendar
Php AES encryption and decryption
Php code, php provides many good things and uses functions directly. However, php currently only knows the ZeroPadding mode, so other languages can only follow it:
$ PrivateKey = "123456781
PHP lists all databases in MySQL
Define ('nl ', "\ n ");
Define ('TB ','');
// Connecting to MySQL.
$ Conn = @ mysql_connect ('localhost', 'username', 'password ')
Or die (mysql_errno (). ':'.
PHP mandatory file download
If you need to download a specific file without opening a new window, the following code snippets can help you.
Function force_download ($ file)
{
$ Dir = "../log/exports /";
If (isset ($
PHP prevents multiple IP addresses from accessing your website
This code snippet allows you to prohibit certain IP addresses from accessing your website.
If (! File_exists('blocked_ips.txt ')){
$ Deny_ips = array (
'2017
Nobackend is used in website architecture
Nobackend is used in website architectureThe current application development model places too much emphasis on backend construction. In fact, we have already done many years of work to simplify
This article explains in detail how PHP randomly retrieves several different numbers from an array.
PHP randomly retrieves several different numbers from an array.
The first algorithm, other people's ideas on CSDN
$ Num = 0; $ array = array (1, 2, 3
Php script for uploading files through ftp
The general principle is to traverse all non-exclusive files in the project and then obtainThe file modification time is later than the last modification time of the file.And then upload these
Search Chinese characters or English letters by the first letter in PHP
/**
*
*/
Function getfirstchar ($ s0 ){
If ($ s0 [0] = 'I' | $ s [0] = 'I '){
Return "I ";
} Elseif ($ s0 [0] = 'U' | $ s [0] =
Obtain the PHP code of the user's IP address
Function getRealIpAddr ()
{
If (! Empty ($ _ SERVER ['http _ CLIENT_IP ']) // check ip from share internet
{
$ Ip = $ _ SERVER ['http _ CLIENT_IP '
Basic operations on php files
// Basic file operations
// Fopen ()
Open a file
// Open a file in the absolute path, select read-only mode, and return the resource $ handle
$ Handle = fopen
Php binary search algorithm
// $ Low and $ high have to be integers
Function BinarySearch ($ array, $ key, $ low, $ high)
{
If ($ low> $ high) // termination case
{
Return-1;
}
$
PHP code snippet used to determine the dominant color of an image
This code helps you determine the dominant color of any image and use a simple statistical algorithm.
$ I = imagecreatefromjpeg ("image.jpg ");
For ($
Php calculates the distance between two coordinates (longitude and latitude)
Php calculates the distance between two coordinates (longitude and latitude). The Returned result is meter or kilometer.
Function distance ($ lat1, $
Php redies encapsulation class
/**
* Redis Operations Support Master/Slave load clusters
*
* @ Author jackluo
*/
Class RedisCluster {
// Whether to use the M/S read/write Cluster
Php uses socketpost to send data to other webservers
Function post_request ($ url, $ data, $ referer = ''){
// Convert the data array into URL Parameters like a = B & foo = bar etc.
$ Data = http_build_query ($
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service