PHP Object-oriented Abstract class interface constant learning

Source: Internet
Author: User
Use and definition of PHP abstract classes & lt ;? Phpshortactclassa {public $ name; functionfun () {echo $ this-& gt; name;} abstractfunctioncc ($ n, $ nn = 3);} classBextendsA {functioncc ($ m, $

 

Use and definition of PHP abstract classesName;} abstract function cc ($ n, $ nn = 3);} class B extends A {function cc ($ m, $ mm = 7) {echo "aaa" ;}}$ B = new B ;?> PHP object-oriented interface definitionTwo examples: abstract class example:Host = $ h; $ this-> user = $ u; $ this-> passwd = $ p; $ this-> dbname = $ d; $ this-> charset = $ c; $ this-> conn ();} function conn () {@ mysql_connect ($ this-> host, $ this-> user, $ this-> passwd) or die ("mysql connection failed"); @ mysql_select_db ($ this-> dbname) or die ("database connection failed "); $ this-> q ("set names '". $ this-> charset. "'");} function q ($ n) {return mysql_query ($ n);} function id () {return mysql_insert_id ();} function f ($ n, $ st = 1) {switch ($ st) {c Ase 1: $ rs = mysql_fetch_array ($ n); break; case 2: $ rs = mysql_fetch_row ($ n); break;} return $ rs ;} // ========================================// *** NOTE: into database insertion method * parameter: $ tb table name, $ val indicates the inserted value, $ st debugging method, 1 debugging 0 not debugging * return: int */abstract function into ($ tb, $ val, $ st = 0);/*** NOTE: sel_once query * parameter: $ tb table name, $ wh condition default 1, $ ar field, $ ty query type, default subscript and key name, $ st debugging status, default value: 0, 1 debugging 0 not debugging * return: array [one-dimensional array] */abstract function sel_once ($ tb, $ wh = 1, $ ar = "*", $ ty = 1, $ st = 0);/*** NOTE: sel_al L query * parameter: $ tb table name, $ wh condition default 1, $ ar field, $ ty query type, Default subscript and key name, $ st debugging status, the default value is 0, 1. debug 0. do not debug *. return: array [two-dimensional array] */abstract function sel_all ($ tb, $ wh = 1, $ ar = "*", $ ty = 1, $ st = 0);/*** description: update database method * parameter: $ tb table name, $ val update content $ wh condition [1 limit 1], $ st debug mode default 0, 1 debug 0 not debug * return: int */abstract function update ($ tb, $ val, $ wh = "1 limit 1", $ st = 0);/*** description: del database deletion method * parameter: $ tb table name, $ wh condition [1 limit 1], $ st debugging mode default 0, 1 debugging 0 not debugging * return: int */abstract function del ($ tb, $ wh = "1 limit 1 ", $ st = 0) ;}?> Interface learning example:

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.