Use PHP to convert the URL string into a hyperlink (URL or email)

CopyCodeThe Code is as follows: function makeclickablelinks ($ text ){ $ Text = eregi_replace ('(f | HT) {1} TP: //) [-a-zA-Z0-9 @: % _ + .~ #? & // =] +) ',' \ 1 ', $ text ); $ Text = eregi_replace ('([[: Space:] () [{}]) (www. [-a-zA-Z0-9 @: %

Usage of static variables in PHP

Take a look at the following example: CopyCode The Code is as follows: Function Test () { $ W3sky = 0; Echo $ w3sky; $ W3sky ++; } ?> This function sets $ w3sky to 0 and outputs "0" for each call ". Adding $ w3sky ++ to the variable has no effect,

PHP code for writing text logs

CopyCode The Code is as follows :** * Write a file * @ Param string $ file path * @ Param string $ STR write content * @ Param char $ mode write mode */ Function writefile ($ file, $ STR, $ mode = 'W ') { $ Oldmask = @ umask (0 ); $ Fp = @ fopen ($

PHP code for inserting data in the specified row of the file

CopyCode The Code is as follows: $ arrinsert = insertcontent ("array. php", "abcdef", 3, 10 ); Unlink ("array. php "); Foreach ($ arrinsert as $ value) { File_put_contents ("array. php", $ value, file_append ); } Function insertcontent ($ source, $

Php xml data parsing code

CopyCodeThe Code is as follows: // XML string $ Xml_string = " Foo foo@bar.com foobar foobar@foo.com "; // Load the XML string using simplexml$ Xml = simplexml_load_string ($ xml_string ); // Loop through the each node

Instructions for using reflection technology architecture plug-ins in PHP

The reflection API plug-in method is determined at runtime. Program That is to say, it allows you to create an optional interface method and detect this interface method when you use it for the first time. Only when this interface exists in the

PHP can read random string code

CopyCodeThe Code is as follows :/************** * @ Length-length of random string (must be a multiple of 2) **************/ Function readable_random_string ($ length = 6 ){ $ Conso = array ("B", "C", "D", "F", "g", "H", "J", "K ", "L ", "M",

PHP function usage and Function Definition

The syntax for a function is: Function Definition Method CopyCode The Code is as follows: function "function_name" (arg1, arg2 ...) { [Code to execute] Return [final_result]; } [Final_result] usually returns the variable value from the

PHP UTF-8, Unicode and BOM Problems

I. Introduction UTF-8 is a Unicode character encoding method that is often used in Web applications. The advantage of using UTF-8 is that it is a variable length encoding method, the length of the ansii code is 1 byte. In this way, network

PHP implementation code for deleting image files while deleting records

CopyCode The Code is as follows: $ Cn = mysql_connect ('192. 0.0.1 ', 'root', 'root') or die ('database connect fail '); Mysql_select_db ('test', $ CN ); Mysql_query ("set names 'gbk '"); /* Database creation tutorial Create Database 'test '; Create

Php URL to obtain Function Code (port, etc.) recommended

PHP obtains the current Script URL (only path) CopyCode The Code is as follows: function getcururl () { If (! Empty ($ _ server ["request_uri"]) { $ Scrtname = $ _ server ["request_uri"]; $ Nowurl = $ scrtname; } Else { $ Scrtname = $ _ server

Code for counting the number of times a user accesses a webpage using cookies in PHP

How to Create a cookie? The setcookie () function is used to set the cookie. Note: The setcookie () function must be located before the tag. Create your first PHP cookieWhen you create a cookie and use the setcookie function, you must specify

Allow PHP to support source code for resumable upload

For example, the first request for a file is from 0 to 999 bytes, the second request is from 1000 to 1999 bytes, and so on, each request is 1000 bytes of content, and then Program Use the fseek function to obtain the corresponding file location and

PHP mandatory file download function code (any file format)

CopyCodeThe Code is as follows :/******************** * @ File-path to file */ Function force_download ($ file) { If (isset ($ file) & (file_exists ($ file ))){ Header ("Content-Length:". filesize ($ file )); Header ('content-type:

PHP image size adjustment code

CopyCode The Code is as follows :/********************** * @ Filename-path to the image * @ Tmpname-temporary path to thumbnail * @ Xmax-max width * @ Ymax-max height */ Function resize_image ($ filename, $ tmpname, $ xmax, $ Ymax) { $ Ext = explode

Common PHP code (essential for beginners)

1. Connect to the MySQL database Code $ Connec = mysql_connect ("localhost", "root", "root") or die ("cannot connect to the database server:". mysql_error ()); Mysql_select_db ("liuyanben", $ connec) or die ("the database cannot be selected:".

PHP multi-dimensional array sorting (usort, uasort)

Number index array: Bool usort (array & $ array, callback $ cmp_function) The usort function sorts the specified array (parameter 1) in the specified way (parameter 2. When we want to sort multi-dimensional arrays, each element of the

10 simple PHP string processing methods

1. determine the length of a string This is Article The most obvious example is how to determine the length of a string. Here we cannot help but mention the strlen () function: CopyCode The Code is as follows: $ text = "Sunny Day "; $ COUNT =

PHP multi-condition query instance code

Search. php) 1. Generate a query statement: Copy codeThe Code is as follows: $ Conn = mysql_connect ("localhost", "root ",""); $ Db = mysql_select_db ("lingyun "); $ Query = "select * from message where tradetype = '". $ tradetype. "'"; //

Php flv video time Acquisition Function

Copy codeThe Code is as follows: Function BigEndian2Int ($ byte_word, $ signed = false ){ $ Int_value = 0; $ Byte_wordlen = strlen ($ byte_word ); For ($ I = 0; $ I { $ Int_value + = ord ($ byte_word {$ I}) x pow (256, ($ byte_wordlen-1-$ I )); } If

Total Pages: 12780 1 .... 9262 9263 9264 9265 9266 .... 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.