I often encounter the need to export data from a database to an Excel file. using some open-source class libraries, such as PHPExcel, is indeed easy to implement, but it does not support a lot of data, it is easy to reach the PHP memory usage limit.
Combine objects into a tree structure to represent part-the overall hierarchy, so that the customer's use of a single object and composite object is consistent
The code is as follows:
/**
* Combination mode
*
* The object is combined into a tree
Define a series of algorithms, encapsulate them one by one, and make them replace each other. Changes in the used algorithms can be independent of customers who use them.
The code is as follows:
/**
* Strategy mode (Strategy. php)
*
* Define a
Sometimes we need to add external links, but it is not good for a website to have too many external links, so we can achieve this through navigation. URL jump code
1. Code:
For example, if you save it as aaa. php, you can implement aaa. php? Url
Ensure that a class has only one instance and provides a global access point to it.
The code is as follows:
/**
* Singleton mode
*
* Ensure that a class has only one instance and provides a global access point to it.
*
*/
Class Singleton
Share the second-level classification code output by the recently written smarty template engine, which is mainly controlled by two-dimensional arrays. The data table structure of level 2 classification is as follows:
The PHP code is as follows: The
Php advertisement calling code (supporting Flash call), which is very convenient for loading advertisements on php pages. For more information, see. The call method is as follows: the DebugStr function is similar to an echo function.
The code is
The two-dimensional array sorting method based on letters in PHP is very useful in actual development.
The code is as follows:
/**
* Sort an two-dimension array by some level two items use array_multisort () function.
*
* SysSortArray ($ Array,
There are many methods to prevent repeated form submission. the client script prevents refresh and server token verification. thinkphp has built-in form token verification, which can easily prevent repeated forms from being submitted by ThinkPHP.
A piece of code found online! Then I wrote another piece of code based on phpDOMDocument. For more information, see. Below is the online
The code is as follows:
Class ArrayToXML
{
/**
* The main function for converting to an XML document.
* Pass
The application of forms in websites can be said to be the foundation of websites. there are almost no websites without forms. let's review the usage of forms first.
Text box usage:
Among them, the input types include text, password, and so on.
Today, I reviewed and learned how to implement variables in PHP. by browsing its source code, I found that all data types in PHP are stored through a union. The php language is a weak type language, which is managed by recording the type and value
Arrays are the most basic data structures. array operations are the most frequently used by programmers. Here we will write some common operations as functions. Array summation
Given an integer array a containing n elements, calculate the sum of all
Php getting started to learn how to read and write php files. you can use the following two functions to read files: fread, file_get_contents
The code is as follows:
// Open the file
Using fpw.fopen('tmp.html ', 'r ');
// You can use the
The array_unique () function removes repeated values from the array and returns the result array. When the values of several array elements are equal, only the first element is retained, and other elements are deleted.
Array_unique () definition
This function mainly uses the file modification time function filemtime and the current time-frame subtraction method to determine whether to update the content.
The code is as follows:
// This function uses the file modification time function
Input the UNIX timestamp of the article stored in the database to convert it to a prompt such as a few minutes ago, a few hours ago, or a few days ago. For example, Weibo seems more user-friendly. okay, go to the code.
The code is as
In php, the two methods of simulating POST data transmission are shared. sometimes you need to simulate and submit data for easy data collection. For more information, see. Method 1
The code is as follows:
$ Ch = curl_init ();
Curl_setopt ($ ch,
Using the explode function, use the string to be replaced as the separator, connect the two array elements to the string to be replaced, and then UPDATE the array for the past few days, A small problem occurs during work. one field of the content
Recently, the shopex online shop system has been installed for vps customers and service hosting customers, and their hosts all report errors. the error features are the same. in response to this error, our company introduced the shopex host error
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