PHP Core Knowledge Points II

Source: Internet
Author: User
Tags md5 encryption php script set cookie

HTTP protocol: Hypertext Transfer Protocol, B/S Architecture project follows basic protocol, browser server communication Fundamentals (Request connection (TCP/IP protocol), connection success, browser send request, server processing request, browser processing result, close connection), HTTP protocol two parts (request, response) , URL, features (support client/server mode, simple fast [just request method and path], flexible [arbitrary data], no connection [only one request per connection], stateless [Transaction not memory capability])

HTTP request: Four part (request line, request header, blank line, request principal), Request line (Request method, request file, Protocol/version), request header (Host,accept-encoding,referer,connection,accept-language, Cookie,user-agent,accept,content-length (POST), if-modified-since (Get), Content-type (POST)), blank line, request body (POST request data), Telnet Impersonation Request

HTTP response: Four parts (status line, response header, blank line, response body), Status Line (Protocol/version, status code, status description), response header (Server,date,last-modified,content-length,content-type, Location,refresh,content-encodeing,cache-control), blank line, response body (content), header cannot be output, header set cookie

Functions that cannot be output before a function call: session_start,setcookie,header,output_buffering

Common response status information: 1XX (server receive request, continue processing), 2XX (Success, $), 3XX (redirect, 302 Redirect, 304 no Modification), 4XX (request error, 404 Not Found, 403 Forbidden), 5XX (server error, 502 invalid response)

PHP Impersonation Response and Request: Response (jump, refresh, send picture, download (application/octet-stream,content-disposition:attachment;filename), request (Fsockopen, Fwrite,feof,fgets,get request, POST request)

Object-oriented: process-oriented (operational flow) and object-oriented (operator body), OOP (a Software Design architecture idea)

Basic concepts: Class (Object abstraction), Object (Instantiation/class type (custom data type)), instantiation, member (variable, function, constant in class)

Syntax operations: Define classes (Class), instantiate (new, with parentheses, without parentheses), cast (object), StdClass (empty Class), Access modifier qualifier (var,public,protected,private, Difference), Object access member (- >), the class has only three members (properties, methods and constants, cannot echo), the value of the property definition must be a fixed value, how to access the private property (method, $this)

Memory Description: Classes, objects, methods, properties (partitioning from space use, non-memory partitioning)

Magic Method: Construction Method (initialization), destructor method (freeing resource, unset object), structuring method privatization

Construction method Compatible: class name method

Case sensitivity: attributes, array subscripts, and variables

Object passing: Reference passing

Object comparison: = = (Homogeneous object with same property value), = = = (Same object)

DB Class: Class file Naming (class name. class.php)

Jobs: Encapsulating GetAll and GetRow methods

Auto Load: Must have class definition before instantiating object, auto Load (__autoload), auto load principle, auto load conflict (spl_autoload_register)

Class constants: Definition (const), memory partitioning, Access (class access, scope resolution operator, object Access (method)), self keyword, self and this difference, magic constant (__CLASS__,__METHOD__)

Static members: definition (Static), properties, methods, access (scope resolution Operators), static properties and constants access differences

Object counter Making: Ideas

Static and non-static methods differ ($this)

Magic method: __tostring () (Echo Object), __clone () (copied into different objects, cloning does not go through the construction method, block cloning (private))

Singleton mode: Concept (one class with only one object), reason (province resources), principle (three private one public)

Factory mode: Concept (Production object), reason (convenient management), Factory singleton mode

Object-oriented is not necessarily class (JS)

Three major features of OOP: encapsulation, inheritance, polymorphism

Encapsulation: Data and data manipulation, process of making classes, hidden object properties and implementation details (privatization), external use of interfaces (limited read and write)

Inheritance: One object uses the properties and methods of another object directly, reducing the duplication of code

Polymorphism: Many different implementations of the interface, not in PHP

Inheritance: Syntax (extends), inheritance principle, inherited member control (protected), inherited access (subclass Access parent class, parent class access subclass)

Inheritance conflict: Override, Control level (subclass is weaker than parent class), Access parent class with the same name Method (parent)

PHP single inheritance, chained inheritance (multiple inheritance), use of inheritance (table class inherits DB Class)

Special classes: Classes that cannot be inherited and classes that can only be inherited, the final class, the final method (which can be inherited but not overridden), abstract (cannot be instantiated), abstract method

Project design: Large project, multi-team (interface Specification, abstract class specification), small project (not used)

Interface: specifically specifies the structure of the class, Syntax (interface), interface body (constants and methods, cannot implement methods, only public), implement Interface (implements), subclasses must implement interface all methods, implement multiple interfaces

Interview question: Does PHP support multiple inheritance? How to simulate? Interface is not a class? Is the interface not an abstract class?

PHP Overloading: Handling When a user action does not exist or is not available for member properties or methods

Property overloading: __get (), __set (), __isset () (called Isset and Empty), __unset () (unset call)

Method overloading: __call (), __callstatic ()

Overload meaning: Limit user operation conditions, error correction

Object save and Restore: file_put_contents save, File_get_contents get, object cannot be saved directly

Serialization: Serialize

Deserialization: Unserialize,php_incomplete_class, cannot get original object reason (resource free), introduce class file to get original object, auto load class, database connection invalidation

Object save and Restore: __wakeup (), __sleep (), array save

Object judgment: instanceof, inheriting objects belong to subclass and parent class

Object involves method: Class_exists,interface_exists,method_exists,get_class (Gets the object class name), Get_parent_class (Gets the parent class name)

Object traversal: Property traversal, General foreach traversal, in-class foreach Traversal ($this), in-Class specific property traversal (iterator predefined interface)

"PDO": PDO, Function (portability), principle, configuration (extension)

PDO main classes: PDO (database connection, SQL Transfer), pdostatement (result set, preprocessing), Pdoexception (PDO exception handling)

PDO class: Constructor (DSN data source, user name, password), object destruction (not provided, unset,null), execute SQL (no result set EXEC (add-in), Lastinsertid; with result set pdostatement query), Error handling (ERRORCODE,ERRORINFO)

Pdostatement class: Correlation function (rowcount,columncount), traversing result set (Fetch[fetch_assoc,fetch_num,fetch_both,fetch_obj,fetch_bound], Bindcolumn,fetchall,fetchcolumn,fetchobject,setfetchmode), preprocessing (prepare[prepare name from ' statement? ', using],execute[ Array parameter],bindparam[recommended, first bound after assignment],bindvalue[not recommended, first assignment after binding, each time to bind]), transaction processing (Begintransaction,commit,rollback)

PDO property setting: Setattribute,getattribute, property name and Value (Pdo::attr_autocommit (1,0), Pdo::attr_case (pdo::case_lower,pdo::case_ upper,pdo::case_natural), Pdo::attr_errmode (pdo::errmode_silent,pdo::errmode_warning,pdo::errmode_exception), Pdo::attr_persistent (True,false))

Pdoexception class: Try-catch-throw

Reflection: Reflection reflection Mechanism, reflection (Reflectionclass::export (Class)), Reflection class interior (new Reflectionclass (Class), Getconstants,getproperties, GetMethods)

Ecshop Installation: Virtual host, GD library extension, configuration database, configure background administrator, install test data, access backstage

Shopping system: Imitation ecshop make a small commodity management and shopping system

Features: Background user login (form, Session,cookie, verification Code), Commodity classification management (infinite Pole classification), Commodity management (file processing, thumbnail, watermark processing, paging, commodity batch management, WYSIWYG editor use), time permitting (foreground product browsing, shopping cart action, User management, etc.)

Design projects: Design projects from the Project manager perspective (Project Architecture (framework, source code, development model), coding structure (project directory Division, functional division)

Current popular development mode: Two development, framework development

Data schema: Data size, update frequency; two big database Camps (SQL,NOSQL), Primary architecture (table, table function, table structure, in-table data relations)

Front desk and backstage: Front desk (user see, display data), backstage (admin view, management data), front and rear desk by function division, art and programmer according to work content Division

Project directory structure, Code Division: Project Sub-background, admin for the background directory, front and rear public part of the foreground includes, background public file Admin/includes, front and rear have default access to the entrance index.php

Project code Design: The data is the core, the code is to access and manage the data; Data is stored in MySQL, PHP accesses the database via db.class.php (includes), logic is separated from the display, and public functions are packaged in class (file upload, image processing, paging)

Background User Login function design: Login form (login, verification code, exit, retrieve password, remember password), admin/templates/login.php, code from simple to complex; A class of transactions request a PHP file (login: admin/privilege.php)

Background Project initialization: Runtime Environment (Error level, error display), basic directory Constants, config file system, common code (auto load function, jump, etc.), admin/includes/init.php

admin/includes/init.php: Encoding settings (header), directory constants (__dir__, backslash handling, root_dir,admin_dir,include_dir,admin_include_dir,admin _TEMPLATE_DIR), 5.3 Low-version directory constants (__FILE__)

Configuration file system:/config/config.php, database connection information, two-dimensional array (easy to distinguish)

Load profile: admin/includes/init.php, Profile directory constants, configuration file Globals ($GLOBALS [' config '])

Run environment settings: Ini_set () (error_reporting,display_errors), error level relationship

Login interface: From Ecshop, JS files, image files, CSS files

Login function: privilege.php implementation, introduction of initialization file, introduction of login.php file, action (distinguish action), if branch judgment action

User Login Form Design: Request privilege.php, design hidden domain act,$_request (gpc,request_order,variables_order)

Verify user information: Design Administrator table (Library, table, field (ID, user name, password, registration time, last logon time and IP)), insert a data, receive user submitted data for validation, database operation (using DB class, one class per table (/includes/ adminTable.class.php))

Table class Design: Inheriting DB class, attribute (Table_name,fields)

Validation call Table class: Auto-Load (/includes/ function.php), the initialization file introduces the common function library, instantiates the Table object (incoming database connection information, connects the database), modifies the instantiation (automatic invocation of the configuration file in the DB Class), authenticates the user with the user name and password (correctly obtains the user information, error returns false), modifies the user password (MD5 encryption)

Working principle Analysis: User request to get verification result

Validation result processing: interface jump (Header,js in PHP document.location.href,html refresh), create jump template/admin/templates/redirect.php, jump function Admin_ redirect calling the Jump function in/includes/function.php,privilege

Verify that the user is logged in: Define variable judgments, get parameters, session data

Open session mechanism: Default off (php.ini Session.auto_start), Session_Start on, $_session (Access session data), session implementation of user login judgment

Session principle: Session_Start () Open session and read session file contents to $_session, script end will $_session content written to session file, and then release $_session variable

Session Cycle: Browser Close session invalidation, browser and server sessions process

Cookie session Technology: Server saves data in the browser, cookie principle, session and cookie Difference

Cookie use: Set cookies, obtain cookies ($_cookie and $_request), modify $_cookie (Invalid access again), cookie variable validity period, session failure principle, clear Cookie (Setcookie), Cookie directory distinction, cookie cross-domain, cookie in disguise save array

Session file: Storage (php.ini in Session.save_path)

Cookie file: Browser-specified storage directory, IE and FF differences, FF view Cookie file

Session Login Decision: User Login session record user information, index.php decision session information, initialization file open session

Simulate session implementation cross-scripting

Frame layout background: Use Ecshop background layout, index.php

index.php implementation: Consistent with privilege.php processing, using the Ecshop template

Log out: Clear session, jump to privilege.php landing page, top.php (target property)

User Information display: $_session, user last logon time (modify last logon time after login)

Session Depth: $_session can only be associative array, session can save the object, session expires by the cookie effect, session file Destruction (Session_destroy,$_session,setcookie), Session layering (Session.save_path, creating folders Manually)

Disable cookies after session use (other way to let the browser with SessionID), a tag automatically carry SessionID (Session.use_trans_id,session.use_only_cookie), PHP script Delivery (manually added, session_id (), Session_name ())

Project exit: Cookie Invalidation

Verification Code: Verification Code meaning (anti-malicious request), principle (Completely Automated public Turing test to tell Computers and humans Apart (fully automated computer and human Turing Test), the verification code content is put to the image), Verification code flow (generate, save to session, add to image, user input, verify), compare Ecshop verification code

GD Library: Image processing extension, GD processing picture flow (create image resource (existing or new), manipulate picture (crop picture, modify picture, fill picture, thumbnail, write verification code), save or output, release resources)

Make verification code: Get Verification Code content, verification code is written to the session, verification code is written to the picture, verification code picture display to the form

Encapsulation Verification Code class: Complex verification code method (background color random, text color random, add pixel points, add interference line)

Project Application Verification Code: request action to obtain a verification code picture, verify the user login using the verification code, new Verification Code method (verification code in the Class), click on the Verification Code picture replacement verification Code (JS)

Save User Login Information: The cookie stores the record ID (user ID), determines whether the user is logged in (judging the session, determines the cookie), and increases the user information through the user ID method, dangerous

Product Classification: Data table Design (primary key, category name, sort, parent ID), insert data, category.php, Commodity Category list interface, modify connection (menu), Commodity classification class, call method of commodity classification, template display categorical data

Infinite Pole classification: principle (find top classification, sub-category), non-recursive implementation (specify parent category), recursion (recursive point, recursive exit), recursive principle, indent (hierarchy identifier), Sort by sort field

Construct table full name: Table name, DB Class table prefix, add table name construct in DB class, use in table class

Assigning Values to field properties: Adding the Get table structure method (get all keys, primary key)

Categorical file access validation: Put login verification into init.php, introduce init.php file validation, detach requests that require authentication (login related does not require authentication, $_server[' Script_name '],basename (), Dir_name ())

Classification operation: Add classification (add form, submit form, process form data, classify storage), classify specify superior classification, array receive data submit data, delete classification (prompt user (JS), determine whether the classification can be deleted (whether the last level), delete classification)

Edit Classification function: Process (user click menu to enter edit, display categorical data, user edit operation, submit form, process edit data)

Re-encapsulation gets data by ID method (repeat, put to DB Class), form add hidden category ID

Product Classification Complete: No product quantity, Category list cache (cache cached, update cache), unlimited pole classification zoom

Commodity Management: Data sheet design (modeled ecshop), data insertion, goods.php, complete product List (menu connection, action processing, data object manipulation, list template, icon)

Paging: Process (determine data display quantity, determine number of pages, limit), paging jump (first, previous, Next, end, number, drop-down)

Project pagination: Modify the profile (number of data bars per page), modify list function (page number, number of displays per page), modify list function (get total record count, data, two-dimensional array), modify call list function

Pagination class: Separate paging without data processing (parameters), HTML (tags, ID)

Delete Product: Processing method (Recycle Bin), add delete flag (modify data table), delete process (confirm (JS), modify delete flag, modify list function, update list)

Recycle Bin operation: Paging display (configuration file, paging class use), restore

New Product: Process (connection, action, table method, template, Tab function)

Insert Function Repeat: Add Insert method (DB class, validate array information, array piece together SQL, return insert result), invoke Insert function

File Upload: Post,enctype (mutipart/form-data), $_files (specially received file data, field description, error description (0 no problem, 1 out of size, 2 out of size, 3 parts uploaded, 4 not uploaded, 6 no Temp folder, 7 File Write Temp folder error), File Upload principle (PHP service side), Move temp file (move_uploaded_file), file validation (size, type, rename, Strrchar)

Image upload class: Configuration file (upload size, upload type (string), upload path), upload naming rules (do not repeat, keep the original suffix, easy to identify (prefix)), File upload process (error judgment, file size judgment, file type judgment, rename, upload success, return new file name), File processing failed item still uploaded (Error prompt)

Product Insertion Process review: Collect form data, set initial values (clicks), Upload file judgments, make thumbnail judgments, invoke models, insert data

Make thumbnails: Process (Get Picture resources (original map, target map), process (adopt, copy), save or output, release resources), sample (rectangular region OK)

Package thumbnail production: Data acquisition (original size, target graph size, function type use), thumbnail ratio (aspect ratio), thumbnail production process refinement (calculate the original width and thumbnail size, determine thumbnail sizes, create image resources (original, thumbnail), sample copy, save output, destroy resources)

Thumbnail filter: Thumbnail size fixed (not enough place filler, make thumbnail background) pros and cons (convenient design display, inconsistent with the original image)

Watermark Making: Logo on the image, two (text, picture), basic flow (original, watermark, merge)

Project watermark: Configuration file, process details (get the original source, judge the watermark resource, get the watermark resource, get the picture width, judge the watermark location, calculate the location of the watermark, determine the merging results, save, return the name of the watermark), modify the name of the uploaded image as a watermark map

MVC: Software design paradigm (model, view, controller controllers), input processing and output separation, MVC framework (functional partitioning m,v,c), PHP code development (mixed, display and logical separation, data logic separated from business logic), Action (c handles a class of transactions, C contains multiple actions), distinguishes (module modules, model, template templates)

Automatic security Update method: Patchwork SQL statements, updates, processes (clean invalid fields, patchwork SQL statements (Update section, condition), force set conditions (judging conditions, automatic analysis of conditions), return to execution results)

Auto Delete: Delete according to ID (single =, array in), flow (parameters add quotation marks, patchwork delete condition, return delete result)

Session Storage: Session into memory, session warehousing (modify session storage mechanism), session warehousing principle, modify the session system (session read and write function), modify the process (prepare read and write methods, Inform the session system (Session_set_save_handler ())

Session table Design: Fields (SessionID, data, expiration time)

Session method Perfect: Read (according to SessionID database query), write (according to sessionid,session data write or update data), open (Extract Public Connection database code), database connection resource scope, Destroy (delete data according to SessionID), recycle (based on configuration cleanup expired Session,expire field), Session configuration (Gc_maxlifetime,gc_probobility,gc_divisor)

Encapsulate Session Class: constructor (set session processor, array pass parameter, open session, turn on parent constructor), refine each method

Session Method execution order (read before collection), modify Read method (do not read expired data, read judgment expire), session destruction (stop writing method)

Online Editor: CKEditor, Introduction, Introduction (JS Introduction, call), save edit data, configure CKEditor (height, toolbar), Ckfinder, profile upload (upload, upload directory)

Single entry

PHP Core Knowledge Points II

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.