The simplest way is to directly use php $ _ SERVER ['http _ referer']If I want to log on to the. php pageNow, go to the B. php page and add the following code in B. php: The code is as follows:Copy code $ Url = $ _ SERVER ['http _
Shopping cart type: shop_cart.phpShopping cart operation: cart_action.phpHome: index.htmlJquery is used for Ajax operations, and a jquery plug-in thickboxLet's not talk about it anymore. You can first look at the effect example.Shop_cart.php is of
Program The code is as follows:Copy code /*** $ Str original string* $ Encoding of the original encoding string. The default value is GBK.* $ Prefix: the prefix after Encoding. The default value is ""* $ Postfix: the suffix after Encoding. The
The code is as follows:Copy code ######## Random ad display ##########Function myads (){$ Dir = "ads"; # set the directory for storing records// $ Dir = "ads"; # set the directory for storing records$ Ads = "$ dir/ads.txt"; # set the ad code file$
Share a regular URL expression written by a colleague. Disadvantages: Chinese URLs are not supported: The code is as follows:Copy code (Http [s] {} | ftp): // [a-zA-Z0-9 \. \-] + \. ([a-zA-Z] {2, 4}) (: \ d + )? (/[A-zA-Z0-9 \.\-~! @ # $ % ^ & *
1. Time conversion function in php The code is as follows:Copy code Strtotime (date ())Date ("Y-m-d H: I", $ unixtime) 2. Obtain the timestamp of today's in php.To obtain the unix timestamp at zero point, you can use $ todaytime = strtotime
Php verifies the ip format program codeIf the website has a form that requires an IP address, verify that the format is correct.Php verifies whether the ip format is correctly implemented using regular expressions. The core code is as follows: The
The so-called paging display means that the result set in the database is manually divided into segments for display. Here two initial parameters are required:How many records per page ($ PageSize )?What is the current page ($ CurrentPageID )?Now,
Common keywords in PHPFinal1. final can only modify classes and methods, but cannot modify member Attributes. Function: a modified class cannot be inherited, and a modified method cannot be overwritten.PHP 5 adds a final keyword. If the method in
The code is as follows:Copy code $ Str = "This line containstliberal rn use of whitespace. nn ";// Remove the start and end spaces.$ Str = trim ($ str );// Remove the blank space crowded with other items$ Str = preg_replace ('/s (? = S)/', '', $
Method 1:Write with serialize, and then output with unserializeSerialize () is to serialize the values of PHP variables such as objects and arrays into strings and store them. serialized strings can be stored elsewhere, such as databases, sessions,
The code is as follows:Copy code /*** PHP obtains a set of random numbers without duplicates.*/$ A = microtime ();Function createRandID ($ m ){// Generate an array from 1 to $ m$ Arr = range (1, $ m );// Disrupt the arrayShuffle ($ arr );//
Simple functions and direct code. The code is as follows:Copy code IT development in the fire age Shortcuts. php code The code is as follows:Copy code $ Shortcut ="[InternetShortcut]URL = http://www.111cn.netIDList = IconFile = http://www.
Note: __errors in autoload () cannot be caught by try-catch. The code is as follows:Copy code Function _ autoload ($ class_name ){Require_once (PATH. '/calsses/'. $ class_name. '. Php ');}$ Obj1 = new mycalss1 (); Register the _ autoload ()
In PHP applications, regular expressions are mainly used:• Regular Expression Matching: matches the corresponding content according to the regular expression.• Regular expression replacement: Match and replace the content according to the regular
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