Php Architect’s ZEND PHP 5 Certification

Transcription

php architect’sphp architect's Zend PHP 5 Certification Study Guide, edited and produced bythe publishers of php architect magazine, provides the most comprehensive andthorough preparation tool for developers who wish to take the exam.This book provides complete coverage of every topic that is part of the exam,including: PHP Basics Functions Arrays Strings and Patterns Web Programming Object Oriented Programming Database Programming Object-oriented Design XML and Web Services Security Streams and Network Programming Differences Between PHP 4 and 5Written by PHP professionals and Zend Certified PHP 5 Engineers Davey Shafik andBen Ramsey, and reviewed by core PHP developer Derick Rethans, this is the perfectbook for every prospective Zend Certified PHP Engineer candidate!USCanadaUK (net) 32.99 42.99 19.99From the publishers ofShelve under PHP/Web Development/Internet Programming7.50 x 9.25D. Shafik / B. RamseyZend's new PHP 5 Certification Exam represent an excellent tool for professionalPHP developers who want to distinguish themselves in their field.php architect’s Zend PHP 5 Certification Guidephp architect’sZend PHP 5 CertificationStudy Guide.571ZEND PHP 5CertificationSTUDY GUIDEDavey Shafikwith Ben Ramsey7.50 x 9.25

php architect’sZend PHP 5 CertificationStudy Guideby Davey Shafikwith Ben Ramsey

php architect’s Zend PHP 5 Certification GuideContents Copyright 2006 David Shafik and Ben Ramsey – All Rights ReservedBook and cover layout, design and text Copyright 2004-2006 Marco Tabini & Associates, Inc. – All Rights ReservedFirst Edition: October 2006ISBN: 0-9738621-4-9Produced in CanadaPrinted in the United StatesNo part of this book may be reproduced, stored in a retrieval system, or transmitted in any form orby means without the prior written permission of the publisher, excet in the case of brief quotationsembedded in critical reviews or articles.DisclaimerAlthough every effort has been made in the preparation of this book to ensure the accuracy of theinformation contained therein, this book is provided “as-is” and the publisher, the author(s), their distributors and retailers, as well as all affiliated, related or subsidiary parties take no responsibility for anyinaccuracy and any and all damages caused, either directly or indirectly, by the use of such information. We have endeavoured to properly provide trademark information on all companies and productsmentioned in the book by the appropriate use of capitals. However, we cannot guarantee the accuracyof such information.Marco Tabini & Associates, The MTA logo, php architect, the php architect logo, NanoBook and theNanoBook logo are trademarks or registered trademarks of Marco Tabini & Associates, Inc.Written byDavey ShafikBen RamseyPublished byMarco Tabini & Associates, Inc.28 Bombay Ave.Toronto, ON M3H 1B7Canada(416) 630-6202 / (877) 630-6202info@phparch.com / www.phparch.comEdited bySean CoatesTechnical ReviewersDerick RethansPaul ReinheimerLayout and DesignArbi ArzoumaniManaging EditorEmanuela Corso

ContentsForewordxvHow To Use This BookChapter 1 — PHP BasicsSyntax . . . . . . . . . . . . . . . . . . .Source Files and PHP Tags . . . .Newline Characters . . . . . . . .Anatomy of a PHP Script . . . . . . . .Comments . . . . . . . . . . . . .Whitespace . . . . . . . . . . . . .Code Block . . . . . . . . . . . . .Language Constructs . . . . . . .Data Types . . . . . . . . . . . . . . . .Numeric Values . . . . . . . . . .Strings . . . . . . . . . . . . . . .Booleans . . . . . . . . . . . . . .Compound Data Types . . . . . .Other Data Types . . . . . . . . .Converting Between Data TypesVariables . . . . . . . . . . . . . . . . .Variable Variables . . . . . . . . .Determining If a Variable Exists .Constants . . . . . . . . . . . . . . . .xvii.33355667788101011111112131414

vi ” CONTENTSOperators . . . . . . . . . . . . . . . . . . . .Arithmetic Operators . . . . . . . . . . .The String Concatenation Operator . .Bitwise Operators . . . . . . . . . . . . .Assignment Operators . . . . . . . . . .Referencing Variables . . . . . . . . . .Comparison Operators . . . . . . . . . .Logical Operators . . . . . . . . . . . . .Other Operators . . . . . . . . . . . . . .Operator Precedence and AssociativityControl Structures . . . . . . . . . . . . . . .Conditional Structures . . . . . . . . . .Iterative Constructs . . . . . . . . . . . .Breaking and Continuing . . . . . . . .Errors and Error Management . . . . . . . .Types of Errors . . . . . . . . . . . . . . .Error Reporting . . . . . . . . . . . . . .Handling Errors . . . . . . . . . . . . . .Summary . . . . . . . . . . . . . . . . . . . . .Chapter 2 — FunctionsBasic Syntax . . . . . . . . . . . . . . .Returning Values . . . . . . . . . . . .Variable Scope . . . . . . . . . . . . . .Passing Arguments . . . . . . . .Variable-length Argument Lists .Passing Arguments by ReferenceSummary . . . . . . . . . . . . . . . . .Chapter 3 — ArraysArray Basics . . . . . . . . . . . .Printing Arrays . . . . . . . .Enumerative vs. AssociativeMulti-dimensional Arrays .Unravelling Arrays . . . . 424345.474748495050.

CONTENTS ” viiArray Operations . . . . . . . . . . . . . . . . . . .Comparing Arrays . . . . . . . . . . . . . . . .Counting, Searching and Deleting ElementsFlipping and Reversing . . . . . . . . . . . . .Array Iteration . . . . . . . . . . . . . . . . . . . . .The Array Pointer . . . . . . . . . . . . . . . .An Easier Way to Iterate . . . . . . . . . . . .Passive Iteration . . . . . . . . . . . . . . . . .Sorting Arrays . . . . . . . . . . . . . . . . . . . . .Other Sorting Options . . . . . . . . . . . . .The Anti-Sort . . . . . . . . . . . . . . . . . .Arrays as Stacks, Queues and Sets . . . . . . . . .Set Functionality . . . . . . . . . . . . . . . .Summary . . . . . . . . . . . . . . . . . . . . . . . .Chapter 4 — Strings And PatternsString Basics . . . . . . . . . . . . . . . . . . . .Variable Interpolation . . . . . . . . . . .The Heredoc Syntax . . . . . . . . . . . .Escaping Literal Values . . . . . . . . . . .Determining the Length of a String . . . .Transforming a String . . . . . . . . . . .Using Strings as Arrays . . . . . . . . . . .Comparing, Searching and Replacing Strings .Simple Searching Functionality . . . . . .Matching Against a Mask . . . . . . . . .Simple Search and Replace Operations .Extracting Substrings . . . . . . . . . . . .Formatting Strings . . . . . . . . . . . . . . . .Formatting Numbers . . . . . . . . . . . .Formatting Currency Values . . . . . . . .Generic Formatting . . . . . . . . . . . . .Parsing Formatted Input . . . . . . . . . .Perl-compatible Regular Expressions . . . . 818183848485878989

viii ” CONTENTSDelimiters . . . . . . . . . . . . .Metacharacters . . . . . . . . . .Quantifiers . . . . . . . . . . . . .Sub-Expressions . . . . . . . . . .Matching and Extracting StringsUsing PCRE to Replace Strings .Summary . . . . . . . . . . . . . . . . .Chapter 5 — Web ProgrammingAnatomy of a Web Page . . . . . . . . . . . . .Forms and URLs . . . . . . . . . . . . . . . . .GET and URLs . . . . . . . . . . . . . . . .Using POST . . . . . . . . . . . . . . . . .When You Don’t Know How Data Is SentManaging File Uploads . . . . . . . . . . .GET or POST? . . . . . . . . . . . . . . . .HTTP Headers . . . . . . . . . . . . . . . . . . .Redirection . . . . . . . . . . . . . . . . . .Compression . . . . . . . . . . . . . . . . .Caching . . . . . . . . . . . . . . . . . . . .Cookies . . . . . . . . . . . . . . . . . . . .Sessions . . . . . . . . . . . . . . . . . . . . . .Summary . . . . . . . . . . . . . . . . . . . . . 7109110Chapter 6 — Object Oriented Programming in PHPOOP Fundamentals . . . . . . . . . . . . . . . . . .Declaring a Class . . . . . . . . . . . . . . . .Instantiating an Object . . . . . . . . . . . . .Class Inheritance . . . . . . . . . . . . . . . .Class Methods and Properties . . . . . . . . . . . .Constructors . . . . . . . . . . . . . . . . . . .Destructors . . . . . . . . . . . . . . . . . . .Visibility . . . . . . . . . . . . . . . . . . . . .Declaring and Accessing Properties . . . . .Constants, Static Methods and Properties . . . . .113113114114115116118119120122123.

CONTENTS ” ixClass Constants . . . . . . . . .Interfaces & Abstract Classes . . . .Interfaces . . . . . . . . . . . . .Determining An Object’s ClassExceptions . . . . . . . . . . . . . . .The Basic Exception Class . . .Throwing Exceptions . . . . . .Lazy Loading . . . . . . . . . . . . . .Reflection . . . . . . . . . . . . . . .Summary . . . . . . . . . . . . . . . .Chapter 7 — Database ProgrammingAn Introduction to Relational Databases and SQLIndices . . . . . . . . . . . . . . . . . . . . . .Relationships . . . . . . . . . . . . . . . . . .SQL Data Types . . . . . . . . . . . . . . . . .Creating Databases and Tables . . . . . . . .Creating Indices and Relationships . . . . .Dropping Objects . . . . . . . . . . . . . . . .Adding and Manipulating Data . . . . . . . .Removing Data . . . . . . . . . . . . . . . . .Retrieving Data . . . . . . . . . . . . . . . . .SQL Joins . . . . . . . . . . . . . . . . . . . . . . . .Outer Joins . . . . . . . . . . . . . . . . . . . .Advanced Database Topics . . . . . . . . . . . . .Transactions . . . . . . . . . . . . . . . . . . .Prepared Statements . . . . . . . . . . . . . .Summary . . . . . . . . . . . . . . . . . . . . . . . .Chapter 8 — Elements of Object-oriented DesignDesign Pattern Theory . . . . . . . . . . . . . . .The Singleton Pattern . . . . . . . . . . . .The Factory Pattern . . . . . . . . . . . . . .The Registry Pattern . . . . . . . . . . . . .The Model-View-Controller Pattern . . . 61

x ” CONTENTSThe ActiveRecord Pattern .The Standard PHP Library . . . .Accessing Objects as ArraysSimple Iteration . . . . . . .Seekable Iterators . . . . . .Recursive Iteration . . . . .Filtering Iterators . . . . . .Summary . . . . . . . . . . . . . .162162163164165166168169Chapter 9 — XML and Web ServicesThe Extensible Markup Language (XML) .Creating an XML Document . . . . . .SimpleXML . . . . . . . . . . . . . . . . . .Parsing XML Documents . . . . . . . .Accessing Children and Attributes . .XPath Queries . . . . . . . . . . . . . .Modifying XML Documents . . . . . .Working With Namespaces . . . . . .DOM . . . . . . . . . . . . . . . . . . . . . .Loading and Saving XML DocumentsXPath Queries . . . . . . . . . . . . . .Modifying XML Documents . . . . . .Moving Data . . . . . . . . . . . . . . .Modifying Data . . . . . . . . . . . . .Removing Data . . . . . . . . . . . . .Working With Namespaces . . . . . .Interfacing with SimpleXML . . . . . .Web Services . . . . . . . . . . . . . . . . . .SOAP . . . . . . . . . . . . . . . . . . .Accessing SOAP-based Web Services .D

21.11.2014 · Study Guide Zend's new PHP 5 Certification Exam represent an excellent tool for professional PHP developers who want to distinguish themselves in their field. php architect's Zend PHP 5 Certification Study Guide, edited and produced by the publishers of php architect magazine, provides the most comprehensive and thorough preparation tool for developers who wish to take the exam.