Summary of php code writing habits Optimization

(1) The static method is four times faster than the normal method.(2) echo output is faster than print(3) Use the connection character instead.(4) take the maximum value before the loop, instead of taking the value in the loop.Correct Method$ Max =

Thinkphp multi-Table transaction details

As follows:Copy codeThe Code is as follows:Function makeAcquire ($ nUsers, $ nAwards){// Update the database$ TranDb = new Model ();$ TranDb-> startTrans ();For ($ I = 0; $ I {// Update the Acquire table$ FlagAc = $ tranDb-> table ('acquire ')-> add

Analysis of memcache applications in php

Required environment:Php 5.3.3Apache 2.2.7Mysql 5.5.8Download related documents:Click to downloadDecompress the memcached_1.2.5file and execute memcached.exe-d-installDecompress the php5.3 _ vc6_memcachedll file and copy the php_memcache.dll file to

PHP retrieves the start date and end date of the Week (month) of the current date (implementation code)

CodeCopy codeThe Code is as follows:// Obtain the start time and end time of the week of the specified date.Function getWeekRange ($ date ){$ Ret = array ();$ Timestamp = strtotime ($ date );$ W = strftime ('% U', $ timestamp );$ Ret ['sdate'] =

Attack CakePHP (Ruby On Rails framework in PHP) graphic introduction page 1/2

CakePHP framework home: http://www.cakephp.org/ Import the downloaded directory to the project. The directory structure is shown in figure (Version: 1.1.19.6305) Set up the PHP environment. Here AppServ2.5.9 is used.Home

Php beginners write small programs that promptly replenish skype users' phone charges

In fact, there are dozens of items, but because there is a large amount of data to be operated, a small program is added to solve the problem. The data that was not processed yesterday can be processed, as shown below:Copy codeThe Code is as follows:

Php project package method page 1/2

Enterprise websites require at least one virtual host. However, OA, finance ...... These internal systems are hard to say. They can't always throw the code and database to others, write a description, let them configure the environment according to

Function Code for PHP integration with FCK

Copy codeThe Code is as follows:// Define a function to call FCKeditorFunction call_fck ($ input_name, $ input_value, $ w = '000000', $ h = '000000 '){Include_once 'fckeditor/fckeditor. php ';$ Fcked = new FCKeditor ($ input_name );$ Fcked->

Analysis on the principle of making a simple content collector using PHP

I developed a novel serialization program a few days ago. For fear of updating problems, I wrote a collector to collect 8-way Chinese network. The function is simple and cannot be customized, however, the general idea is in place, and custom rules

Php optimization and efficient acceleration implementation method page 1/2

1. In a function, it is more efficient to use return when passing an array than to use global. For example: Function userloginfo ($ usertemp ){$ Detail = explode ("|", $ usertemp );Return $ detail;}$ Login = userloginfo ($ userdb );RatioFunction

Php Chinese processing function set

--- Space ---String GBspace (string) --------- Add a space between each textString GBunspace (string) ------- clear spaces between each textString clear_space (string) ------- used to clear unnecessary Spaces--- Conversion ---String GBcase (string,

Php cache Function Code

Copy codeThe Code is as follows:*** @ Note: File Cache output* @ Parameter: $ cachefile => cache file (absolute path)* @ Parameter: $ pertime => cache output Interval* @ Parameter: $ SQL => SQL statement* @ Parameter: $ templatefile => template file

Php code for generating random numbers or strings

$ Len indicates the length. The Code is as follows:Copy codeThe Code is as follows:/*** Generate random strings** Generates a random string of the specified length and returns it to the user.** @ Access public* @ Param int $ len: number of digits of

Php automatically jumps to Chinese and English pages

PHP code:$ Lan = substr (? $ HTTP_ACCEPT_LANGUAGE, 0, 5 );If ($ lan = "zh-cn ")Print (" ");ElsePrint (" ");?>HTML web pages automatically jump to multilingual pages based on different browser languagesAdd the following code between .

Php checks whether the string is UTF-8 encoded.

Function is_utf8 ($ string ){Return preg_match ('% ^ (? :[\ X09 \ x0A \ x0D \ x20-\ x7E] # ASCII| [\ XC2-\ xDF] [\ x80-\ xBF] # non-overlong 2-byte| \ XE0 [\ xA0-\ xBF] [\ x80-\ xBF] # excluding overlongs| [\ XE1-\ xEC \ xEE \ xEF] [\ x80-\ xBF] {2}

Php implements a function for converting Arabic numerals to Chinese numerals

If you want to convert the amount, modify the processing of the decimal part.Function ch_num ($ num, $ mode = true ){$ Char = array ("zero", "one", "two", "three", "Si", "Wu", "Lu", "Jun ", "success", "fail ");$ Dw = array ("", "Pick", "audio",

Application on the session logon page in PHP4

// This script is used to enter a password for the user and determine whether the password is correct.// If it is correct, go to the welcome page.If ($ login ){Include ("../include/config. inc. php3 ");Session_start ();$ Right_enter = '0 ';$ Query =

PHP learning mysql 1/2 page

Data TypeInteger: It can be expressed in decimal or hexadecimal notation.Point: A floating point number is composed of a number plus a decimal point and a number. The two numeric sequences cannot be empty at the same time.String: a character or

Quick PHPMyAdmin Configuration

Now we start to install and configure:1. The PHPMyAdmin package downloaded from the internet is usually released to the htdocs directory, for example, htdocs \ phpmyadmin.2. Open the phpmyadmin directory and check whether the config. sample. inc.

Incorrect Date acquisition time in PHP

When echo $ showtime = date ("Y-m-d H: I: s") is used to obtain the system time today, it is found that the obtained time is inconsistent with the system time.After some research, we found that the default time set by PHP is based on Greenwich Mean

Total Pages: 12780 1 .... 12017 12018 12019 12020 12021 .... 12780 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.