A simple PHP Custom exception class

/** * Customize an exception handling class */ Class MyException extends Exception { Redefine the constructor to make the message a property that must be specified Public function __construct ($message, $code = 0) {

How PHP adds and removes array elements

$fruits = Array ("Apple", "banana"); Array_unshift ($fruits, "orange", "pear") $fruits = Array ("Orange", "pear", "apple", "banana"); Copy CodeAdd an element at the end of an arrayThe return value of the Array_push ()

Exception handling, error throwing, and error callback functions in PHP

try{ You codes this maybe cause an error }catch (Exception $err) {//This Error object needs to declare type, Exception is the system default exception handling class echo $err->getmessage (); } Thrown can throw an

Ajax and PHP implementation code for passing and receiving variables

$.ajax ({ URL: ' query.php ', Data: {id:10}, Datatype:json Success:function (Results) { if (results.msg = = ' success ') { for (var i in data) { $ (' #content '). Append ( ' id = ' +

PHP implementation of the file download in IE code

if (Empty ($_get[' FileName ']) | | empty ($_get[' Filedir ')) | | empty ($_get[' FileId '])) { Echo '; Exit (); } $file _name=$_get[' FileName '; $file _dir=$_get[' Filedir ']; $FileId =$_get[' FileId '];

A detailed description of the private property inheritance problem for PHP classes

Class employee{ Private $sal = 3000; protected $sal = 3000; Public Function Getsal () { return $this->sal; } } Class Manager extends Employee { protected $sal = 5000; Public Function

PHP code to verify user-entered mailbox validity and correctness

!--? php function validate_email ($email) { $exp = "^[a-z ' 0-9]+ ([. _- ][a-z ' 0-9]+) *@ ([a-z0-9]+ ([. _-][a-z0-9]+)] +$ "; if (eregi ($exp, $email)) {//Use regular expressions to verify the validity

Phpmailer instructions for use in Chinese

Phpmailer Chinese use instructions, the need for friends to take it.A begins with:$AltBody--Properties derived from: Phpmailer: $AltBody file: Class.phpmailer. PHP Description: The setting of this property is an alternate display of HTML that is not

Several methods for SQL prevention injection in PHP

/** * Anti-SQL injection * @author: test@jbxue.com * */ /** * Reject SQL Inject */ if (!function_exists (quote)) { function quote ($VAR) { if (strlen ($var)) {

PHP implementation of long article page display code

/** *author: Black Bird Heart * Code to implement long article pagination Principle * Use an array to record every page of the article (with P0, p1, p2 ... do a manual tag), and then use the PHP function to manipulate the array

PHP program randomly records MySQL rand () resulting in CPU 100% workaround

$idlist = "; for ($i =1; $i if ($i ==1) { $idlist =mt_rand (3,25216); } else{ $idlist = $idlist. ', '. Mt_rand (3,25216); } } $query = "SELECT * from table where ID in ($idlist) LIMIT 0,10";

Code that PHP uses Mysql_data_seek to move the pointer to the initial location of the dataset

Start Snipit 1 $sql = "SELECT * from"$result = mysql_query ($sql); "; while ($row = Mysql_fetch_assoc ($result)) { Do stuff with $row } Mysql_data_seek ($result, 0); The point is here. while

Summary of the usage of eval function in PHP

$string = "Beautiful"; $time = "Winter"; $str = ' This is a $string $time morning! '; echo $str. ""; Eval ("$str =" $str ";"); Echo $str; ?> Copy CodeOutput: This is a $string $time morning! This

How PHP Gets the client browser and operating system information

Display the browser information of the Access user Echo ' Browser: '. Determinebrowser ($Agent). ''; Show access to the user's operating system platform Echo ' Platform: '. Determineplatform ($Agent). ''; A positive value

PHP write recursive list of all files and directories functions

!--? php /* Simple directory recursive functions */ function tree ($directory) { $mydir =dir ($directory); echo " "; while ($file = $mydir->read ()) {

PHP XML Operation class (custom)

/** PHP XML Operation class link:http://bbs.it-home.org */ Class Requirelog { protected static $requirelog; Get ready for xml,if XML is not found, create XML static function _initializelog () { if

PHP Call WebService methods for passing time parameters

When WebService docking with other systems, PHP was unable to recognize the time parameters under. Net. Parsing: Calling WebService code in PHP is done by hand-writing XML-formatted packets.When WebService docking with other systems, PHP was unable

PHP automatically generate monthly calendar code

/** PHP automatically generate monthly calendar Link:bbs.it-home.org 2013-3-7 */ function Calendar ($MM, $YYYY) { if ($MM = = "") $MM = Date ("M"); if ($YYYY = = "") $YYYY = Date ("Y"); if (Checkdate ($MM, 1, $YYYY)

Several ways to get file extensions in PHP

PHP get the file extension of several methods, the need for friends can refer to the next.Method 1:function Get_extension ($file) {substr (STRRCHR ($file, '. '), 1);}Method 2:function Get_extension ($file) {return substr ($file, Strrpos ($file, '. ')

A simple example of a Word file generated by PHP

/** PHP generates Word files link:bbs.it-home.org */ $word = new COM ("Word.Application") or Die ("Cannot Start Word program! "); $word->visible = 0; $n = $word->documents->add (); # # sub-section symbol

Total Pages: 5208 1 .... 3119 3120 3121 3122 3123 .... 5208 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.