A simple php custom exception class
/**
* Custom exception handling class
*/
Class MyException extends Exception
{
// Redefine the constructor to make the message a required attribute
Solution to the Notice: Undefinedindex error prompt in php
If (array_key_exists ('strue ', $ _ POST ))
{
If ($ _ POST ['strue'])
{
$ Istrue = $ _ POST ['strue'];
}
} Else {
$ Istrue = '';
Two methods for php to automatically generate a new password
/*
* Php automatically generates a new password user-defined function
Applicable environment: PHP5.2.x/mysql 5.0.x
Code author: xujiajay
Automatically generate the php code for the document summary
// PHP 4.3 or above needed
Define ("BRIEF_LENGTH", 800); // Word amount of the Briefing of an Article
Function Generate_Brief ($ text ){
A simple example of generating a word file using php
/**
Php generates word files
Link: bbs.it-home.org
*/
$ Word = new COM ("word. application") or die ("The Word program cannot be started!
Example of generating word in php
// Generate word
Header ("Content-Type: application/msword ");
Header ("Content-Disposition: attachment; filename = \" file.doc \"");
?>
Php automatically generates the calendar code
/**
Php automatically generates a calendar
Link: bbs.it-home.org 2013-3-7
*/
Function calendar ($ MM, $ YYYY ){
If ($ MM = "") $ MM = date ("m ");
Code for uploading images and creating thumbnails in the phpGD Library
Image Upload -bbs.it-home.org
File upload (only jpg images can be uploaded)
2. process
Php can be used to obtain the real IP address of the Internet.
Function get_onlineip (){
$ Ch = curl_init ('http: // www.ip138.com/ip2city.asp ');
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true );
$ A
Code for converting php xml to an array
// Xml to array, including the root key, ignore empty elements and attributes, there are still major errors
Function xml_to_array ($ xml)
{
$ Reg = "/] *?>
Php Data Backup: single table backup, full table backup, import to database
Class Db
{
Var $ conn;
Function Db ($ host = "localhost", $ user = "root", $ pass = "root", $ db = "test ")
{
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