Functions used to filter HTML code in php

/*----------------------Functions used to filter HTML code-----------------------*/Function htmlEncode ($ string ){$ String = trim ($ string );$ String = str_replace ("&", "&", $ string );$ String = str_replace ("'", "'", $ string );$ String =

[PHP] practical function 2

1. generate random string functionsCopy codeThe Code is as follows:Function random ($ length ){$ Hash = @#@#;$ Chars =@# ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz @#;$ Max = strlen ($ chars)-1;Mt_srand (double) microtime () * 100

PHP static News list automatically generated code

Function CreateShtml (){Ob_start (array ("callback_CreateShtml", "callback_GoToShtml "));}Function callback_CreateShtml ($ buffer){$ Page = intval (@ $ _ REQUEST ["page"]);$ FileName = $ _ SERVER ['document _ root']. dirname ($ _ SERVER ['php _ SELF

Pagination in PHP

// Establish a database connection$ Link = mysql_connect ("localhost", "root", "wyh7ye ");; // Obtain the current page numberMysql_select_db ("test", $ link );If (isset ($ _ GET ['page'])... {$ Page = intval ($ _ GET ['page']);}Else ...{$ Page = 1;}/

Detailed description of php fsockopen forgery post and get Methods

Fsockopen spoofs the post and get methods. If you are looking for php processing code that spoofs the post and get methods, this is good.Copy codeThe Code is as follows:// Fsocket simulate post submission$ Purl = "http: // localhost/netphp/test2.php?

Php anti-injection, implementation of Form submission value escaping

During development, we should pay attention to preventing SQL injection. Therefore, we must process the values submitted in the form to update the data to the database.Php functions. Any value can be passed for conversion.Copy codeThe Code is as

PHP + Tidy-perfect XHTML correction + Filtering

Input and OutputInput and output are the basic functions of many websites. User input data, website output data for others to browse.Take the popular Blog as an example. The input and output here is the Blog article page generated by the author

Control PHP output: cache and compress dynamic pages

Mod_gzip is an Apache module that uses Gzip to compress static html pages. IETF-compliant browsers can accept gzip encoding (IE, Netscape, etc ). Mod_gzip can increase the page download time by 4-5 times. I strongly recommend that you use mod_gzip

PHP-based operations on XML

$ Xml = simplexml_load_file ('example. xml'); // create a SimpleXML objectVar_dump ($ xml); // output XML?> $ Xml = simplexml_load_file ('example. xml'); // read the xml fileForeach ($ xml-> depart as $ a) // read each depart tag in XML data

How to zoom in or out images using PHP

Copy codeThe Code is as follows:Function resizeimage ($ srcfile, $ mySize ){$ Size = getimagesize ($ srcfile );Switch ($ size [2]) {Case 1:$ Img = imagecreatefromgif ($ srcfile );Break;Case 2:$ Img = imagecreatefromjpeg ($ srcfile );Break;Case 3:$

Analysis on efficiency and stability of file_get_contents and curl

I have done a lot of products that crawl content from other websites and get used to using the convenient and fast file_get_contents function. However, I always encounter the problem of failed access, even though I set the timeout according to the

PHP CodeBase: display the time as & quot; n minutes/hour ago &

In many cases, in order to display the timeliness of information, the time is usually displayed as "just", "5 minutes ago", "3 hours ago", and so on, instead of printing the time directly. For Weibo, SNS applications use this function for the

A detailed description of common php self-built functions in some php Projects

The following php functions are the most commonly used project development functions of it Power. These functions are used in many projects and are also quite common.1. processing functions of the Request InterfaceCopy codeThe Code is as follows:/***

Usage of php serialize () and unserialize ()

Serialize () and unserialize () are described in the php manual as follows:Serialize-Generates a storable representation of a valueSerialize-generate a representation of a stored valueUnserialize-Creates a PHP value from a stored

A small example of php caching images generated by gd to memcache

Copy codeThe Code is as follows:// Start to cache ImagesOb_start (); // enable the output cache to temporarily cache the output contentImagejpeg ($ newimage, false, $ quality); // output$ Data = ob_get_contents (); // obtain the cache YOU JUST

Php-based running Modes on various web servers

I. php running mode in apache Php is common in apache.Three working modes: CGI Mode, FastCGI mode, and Apache module DLLComparison:1. Comparison between CGI Mode and module mode:Difference between the two working methods of php in apache (CGI Mode

Common PHP-based Asynchronous execution methods

1. Client pages use AJAX technology to request serversAdvantages:The simplest and fastest way is to embed AJAX calls in the HTML code returned to the client, or embed an img tag. src points to the time-consuming script to be

Online staff function library implemented by php

// Add usersFunction AddUser ($ username ){Global $ db;$ Ip = getenv ('remote _ ADDR ');$ Ip1 = getenv ('HTTP _ X_FORWARDED_FOR ');If ($ Ip1! = "") & ($ Ip1! = "Unknown") $ Ip = $ Ip1;$ Current_time = date ("Y-m-d H: I: s ");$ SQL = "select user

From the perspective of experiences, php and mysql have solid basic skills.

I. 10 sentences1. do not rely ON the register_global = ON environment. From the day when you have just learned how to configure the php runtime environment and even do not understand the impact of register_global ON/off on yourself, we should be

Mysql + php paging class (tested)

Copy codeThe Code is as follows:/*Mysql_pager.class.phpThree parameters. Mysql_query () result, url variable page, the number of records per page you wantThe example is at the bottom of the file.Danshui Riverside Sorting Test*/Class mysql_pager {//

Total Pages: 12780 1 .... 12022 12023 12024 12025 12026 .... 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.