1. Trang chủ
  2. » Khoa Học Tự Nhiên

Teach your self PHP

593 66 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] • • Table of Contents Index Sams Teach Yourself PHP in 24 Hours, Third Edition By Matt Zandstra Publisher: Sams Publishing Pub Date: December 23, 2003 ISBN: 0-672-32619-1 Pages: 500 A quick, easy-to-understand introduction to creating dynamic Web sites with PHP 5, the latest version of this popular programming language Updated and revised to cover features of the latest version of PHP,PHP Quickly teaches the reader the basics of PHP and how to make use of it in practical applications Teaches the reader to create dynamic Web applications and set-up a secure PHP environment [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] • • Table of Contents Index Sams Teach Yourself PHP in 24 Hours, Third Edition By Matt Zandstra Publisher: Sams Publishing Pub Date: December 23, 2003 ISBN: 0-672-32619-1 Pages: 500 Copyright About the Author Acknowledgments Tell Us What You Think! Introduction Who Should Read This Book? How This Book Is Organized Part I: Getting Started Hour PHP: From Home Page to Web Enterprise What Is PHP? What Need Does PHP Fulfill? What's New in PHP The Zend Engine Why Choose PHP? What's New in This Edition Summary Q&A Workshop Exercise Hour Installing PHP Platforms, Servers, Databases, and PHP Where to Find PHP and More Installing PHP for Linux and Apache Some configure Options Configuring Apache php.ini Help! Summary This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Summary Q&A Workshop Exercise Hour A First Script Our First Script Combining HTML and PHP Adding Comments to PHP Code Summary Q&A Workshop Exercise Part II: The Language Hour The Building Blocks Variables Data Types Operators and Expressions Constants Summary Q&A Workshop Exercises Hour Going with the Flow Switching Flow Loops Code Blocks and Browser Output Summary Q&A Workshop Exercises Hour Functions What Is a Function? Calling Functions Defining a Function Returning Values from User-Defined Functions Dynamic Function Calls Variable Scope Saving State Between Function Calls with the static Statement More About Arguments Creating Anonymous Functions Testing for Function Existence Summary Q&A Workshop Exercise Hour Arrays What Is an Array? Creating Arrays Associative Arrays Multidimensional Arrays Accessing Arrays Manipulating Arrays Sorting Arrays This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Functions Revisited Summary Q&A Workshop Exercises Hour Working with Strings Formatting Strings Investigating Strings Manipulating Strings Summary Q&A Workshop Exercises Hour Objects What Is an Object? Creating an Object Object Properties Object Methods Limiting Access to Object Properties Limiting Access to Object Methods Constraining Arguments to Methods with Hints Inheritance Testing Classes and Objects Automatically Loading Include Files with _autoload() Storing and Retrieving Objects Summary Q&A Workshop Exercises Part III : Working with PHP Hour 10 Working with Forms Superglobal Variables The $_SERVER Array A Script to Acquire User Input Importing User Input into Global Scope Accessing Form Input with User-Defined Arrays Combining HTML and PHP Code on a Single Page Using Hidden Fields to Save State Redirecting the User File Upload Forms and Scripts Summary Q&A Workshop Exercises Hour 11 Working with Files Including Files with include() Using include_once() and include_path to Manage Larger Projects Testing Files Creating and Deleting Files Opening a File for Writing, Reading, or Appending Reading from Files Reading the Contents of a File with file_get_contents() This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Writing or Appending to a File Writing Data to a File with file_put_contents() Working with Directories Summary Q&A Workshop Exercises Hour 12 Working with the DBA Functions Beneath the Abstraction Opening a Database Adding Data to the Database Amending Elements in a Database Reading from a Database Determining Whether an Item Exists in a Database Deleting an Item from a Database Adding Complex Data Structures to a Database An Example Summary Q&A Workshop Exercises Hour 13 Database Integration—SQL A (Very) Brief Introduction to SQL Connecting to the MySQL Database Server Selecting a Database Finding Out About Errors Adding Data to a Table Acquiring the Value of an Automatically Incremented Field Accessing Information Changing Data SQLite: A Lightweight SQL Engine Selecting Data Using the PEAR DB Package Summary Q&A Workshop Exercises Hour 14 Beyond the Box Server Variables Revisited A Brief Summary of an HTTP Client/Server Negotiation Getting a Document from a Remote Address Converting IP Addresses and Hostnames Making a Network Connection Sending Mail with the mail() Function An Introduction to Streams Summary Q&A Workshop Exercises Hour 15 Images On-the-Fly Checking Your Configuration with gd_info() Creating and Outputting Images This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Acquiring Color Drawing Lines Applying Color Fills Drawing an Arc Drawing a Rectangle Drawing a Polygon Making a Color Transparent Working with Text Bringing It Together Summary Q&A Workshop Exercises Hour 16 Working with Dates and Times Getting the Date with time() Converting a Timestamp with getdate() Converting a Timestamp with date() Creating Timestamps with mktime() An Example A Date Pull-down Library Summary Q&A Workshop Exercise Hour 17 Advanced Objects Objects and Constants Static Properties Static Methods Intercepting Calls to Object Properties and Methods Final Methods Cleaning Up Using Destructors Managing Error Conditions with Exceptions Tools for Building Object Hierarchies Passing and Assigning Objects Summary Q&A Workshop Exercises Hour 18 Working with Regular Expressions Perl Compatible Regular Expressions Summary Q&A Workshop Exercise Hour 19 Saving State with Cookies and Query Strings Cookies Setting a Cookie with PHP Working with the Query String Creating a Query String Summary Q&A Workshop This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Exercises Hour 20 Saving State with Session Functions What Are Session Functions? Starting a Session with session_start() Working with Session Variables Destroying Sessions and Unsetting Elements Passing Session IDs in the Query String Encoding and Decoding Session Variables Summary Q&A Workshop Exercises Hour 21 Working with the Server Environment Opening Pipes to and from Processes with popen() and proc_open() Running Commands with exec() Running External Commands with system() or the Backtick Operator Plugging Security Holes with escapeshellcmd() Running External Applications with passthru() Calling an External CGI Script with the virtual() Function Summary Q&A Workshop Exercises Hour 22 XML What Is XML? XML Parser Functions An Introduction to the DOM XML Functions XSL: A Brief Discussion Introducing SimpleXML Summary Q&A Workshop Exercises Part IV: Extending PHP Hour 23 PEAR: Reusable Components to Extend the Power of PHP What Is PEAR? Some PEAR Packages in Action PEAR and Your Own Code Summary Q&A Workshop Exercises Hour 24 Toward a Framework for Larger Projects Principles and Problems The Controller Object The RequestHelper and DataStore Classes The CommandFactory Class The Command Class The Dispatcher Class Working with the Framework Where Now, and Was It Worth It? Summary This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Q&A Workshop Exercises Glossary Index [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] Copyright Copyright © 2004 by Sams Publishing All rights reserved No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher No patent liability is assumed with respect to the use of the information contained herein Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions Nor is any liability assumed for damages resulting from the use of the information contained herein Library of Congress Catalog Card Number: 2003109402 Printed in the United States of America First Printing: December 2003 06 05 04 03 Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized Sams Publishing cannot attest to the accuracy of this information Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark Warning and Disclaimer Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied The information provided is on an "as is" basis The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book or from the use of the programs accompanying it Bulk Sales Sams Publishing offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales For more information, please contact: U.S Corporate and Government Sales 1-800-382-3419 corpsales@pearsontechgroup.com For sales outside of the U.S., please contact: International Sales +1-317-581-3793 international@pearsontechgroup.com Acquisitions Editor Shelley Johnston Development Editor Scott D Meyers Managing Editor Charlotte Clapp Project Editor George Nedeff Production Editor Megan Wade Indexer This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Indexer Heather McNeill Proofreader Juli Cook Technical Editors Steph Fox Brian France Sara Goteman Chris Newman Team Coordinator Vanessa Evans Designer Gary Adair Page Layout Stacey Richwine-DeRome Dedication For my father Who would have approved [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com tokenizing 2nd 3rd white space, deleting strings pattern matching [See pattern matching] strip_tags() function 2nd strlen() function strpos() function 2nd strstr() function 2nd strtok() function 2nd 3rd strtolower() function strtoupper() function structure if statement 2nd Structured Query Language [See SQL] subclasses functions, overriding subpatterns 2nd subpatterns [See atoms] subscript() function substr() function 2nd substr_replace() function 2nd substrings finding 2nd position, finding 2nd replacing 2nd superglobal variables 2nd $_COOKIE $_ENV $_FILES $_FILES array 2nd $_GET $_GLOBALS $_POST $_REQUEST $_SERVER 2nd $_SERVER;elements 2nd $_SERVER;looping through 2nd switch statement 2nd 3rd system() function external commands, running 2nd [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] tables data additions 2nd 3rd data additions rows adding unique IDs rows/fields, listing all 2nd SQLite creating 2nd data additions 2nd updating updating tags ASP 2nd code blocks 2nd DocBlocks 2nd end 2nd HTML pre script short standard start 2nd XML 2nd tagWrap() function target character encoding (XML) TaskFacade class 2nd 3rd Telnet clients template method patterns ternary operator 2nd testing Apache DSO support classes/methods existence 2nd context resources data types functions 2nd date files file_exists() function is_dir() function is_file() function multiple file tests 2nd function existence 2nd 3rd scripts 2nd text images 2nd 3rd 4th variable types text bar chart example 2nd 3rd images adding with imagestring() function 2nd adding with imageTTFtext() function 2nd 3rd aligning 2nd 3rd testing 2nd 3rd 4th This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com TrueType fonts strings numbers as 2nd wrapping 2nd text nodes (XML) 2nd time timestamps converting 2nd 3rd 4th creating 2nd Unix epoch time() function date, getting time [See date/time] timestamps converting date() function 2nd getdate() function 2nd creating mktime() function 2nd toArray() function Config_Container class tokenizing strings 2nd 3rd Tom Christiansen Perl Web site toString() function Config_Container class tracking site usage example 2nd 3rd 4th 5th 6th database fields limitations tracking users 2nd 3rd usage statistics, outputting 2nd user information, adding 2nd 3rd transform_to_xml() function transparent colors images 2nd trees XML on-deman function navigation 2nd recursion navigation 2nd text nodes trim() function 2nd TrueType fonts Type fonts support type specifier type specifiers strings 2nd 3rd 4th types data converting 2nd special 2nd standard testing 2nd variables 2nd variables converting 2nd displaying testing This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] U \ modifier ucwords() function Unix grep command 2nd 3rd Unix epoch Unix who command, reading unlink() function unserialize() function 2nd unset() function update() function object hierarchies updating SQLite tables tables uploading files forms scripts urlencode() function user input adding to databases 2nd escaping 2nd HTML forms accessing with SELECT elements 2nd 3rd importing into global variables 2nd reading 2nd 3rd receiving importing into global variables user-agent client header user-defined functions values, returning 2nd users redirecting (forms) 2nd 3rd users array elements usr/local/lib directory php.ini file location [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] values functions returning 2nd return included documents 2nd storing variables remembering between function calls 2nd 3rd var keyword object properties var_dump() function 2nd variable directives variables 2nd array session registration 2nd arrays adding 2nd casting 2nd 3rd counter data types 2nd functions accessing 2nd 3rd 4th scope 2nd global accessing user input, importing 2nd integer decrementing 2nd incrementing 2nd naming 2nd server 2nd listing of 2nd session accessing 2nd 3rd 4th encoding/decoding 2nd registering superglobal 2nd $_COOKIE $_ENV $_FILES $_FILES array 2nd $_GET $_GLOBALS $_POST $_REQUEST $_SERVER 2nd 3rd 4th 5th 6th types converting 2nd displaying testing values remembering between calls 2nd remembering between function calls 2nd 3rd variables [See also properties] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com version (@before) tag viewing spaces HTML documents virtual() function [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] w \escape character W \escape character WBMPs support Web browsing Telnet security Web istes PHP Web pages retrieving fsockopen() function retrieving/printing with fopen() function 2nd Web servers returned status lines, outputting 2nd Web sites calendar functions CURL package DOM W3C specification FreeType Front Controller pattern Independent JPEG Group J2EE patterns libxml2 libxslt Linux Mac OS X PHP installation mailing list archives MySQL 2nd NetCraft PEAR PEAR style guide Perl Perl regular expressions PHP 2nd PHP Builder PHP editors PHP mailing lists 2nd PHP manual 2nd 3rd 4th PHP(|)architect php.MVC phpdoc command flags PHPDocumentor phpPatterns Phrame storage drivers stream wrappers string functions Tom Christiansen Perl Web security Windows PHP installation XHTML 2nd XML This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com XML Parser Toolkit Yellow Dog Linux Zend while loop while statement 2nd white space (strings) deleting who command (Unix), reading Windows PHP installation Web site with-adabas ( ) option configure script with-dba ( ) option configure script with-dbm ( ) option configure script with-filepro ( ) option configure script with-freetype ( before) option (configure script) with-gd ( before) option (configure script) with-gdbm ( before) option (configure script) with-gdbm ( ) option configure script with-informix ( ) option configure script with-iodbc ( ) option configure script with-ldap ( ) option configure script with-msql ( ) option configure script with-mysql ( before) option (configure script) 2nd with-openlink ( ) option configure script with-oracle ( ) option configure script with-pgsql ( ) option configure script with-solid ( ) option configure script with-sybase ( ) option configure script with-sybase-ct ( ) option configure script with-velocis ( ) option configure script with-xslt ( before) option (configure script) wordwrap() function 2nd wrappers streams wrappers (HTTP) context options wrapping text strings 2nd write_login() function writeConfig() function Config class writeObject() function writing This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com data to files file_put_contents() function 2nd files fopen() function 2nd fwrite() function 2nd processes 2nd 3rd [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] x \ modifier 2nd x type specifiers X type specifiers XBMs support XHTML 2nd (Extensible Hypertext Markup Language) standards XHTML Web site XML case folding declarations document 2nd documents banana-related news site example 2nd creating with DOM functions 2nd errors, reporting 2nd parsing 2nd 3rd 4th 5th 6th parsing with SimpleXML DOM DomDocument objects 2nd DomElement object 2nd DomElement objects 2nd DomText objects 2nd root elements, creating W3C specification XML documents, creating 2nd DTDs elements 2nd case folding handlers 2nd library libxml2 parser functions resources Parser Toolkit SimpleXML 2nd stability support tags 2nd target character encoding text nodes 2nd trees on-demand function navigation 2nd recursion navigation 2nd Web site XML (Extensible Markup Language) XML documents creating with XSL 2nd DOM elements, adding 2nd xml_error_string() function xml_get_current_line_number() function xml_get_error_code() function xml_parse() function This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com xml_parser_create() function xml_parser_free() function xml_parser_set_option() function xml_set_character_data_handler() function 2nd xml_set_default_handler() function xml_set_element_handler() function 2nd xml_set_external_entity_ref_handler() function xml_set_notation_decl_handler() function xml_set_processing_instruction_handler() function xml_set_unparsed_entity_decl_handler() function XPMs support XSL documents 2nd library support XML documents, creating 2nd XSL (Extensible Stylesheet Language) XsltProcessor class [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] year_select() function yearPulldown() function Yellow Dog Linux Web site [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] Z \escape character z \escape character Zend Engine Zend scripting engine Zend Web site [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Brought to You by Like the book? Buy it! ... ] Hour PHP: From Home Page to Web Enterprise What You'll Learn In This Hour: What PHP is About PHP' s history What improvements can be found in PHP Some options that add features to your PHP binary... Exercise Hour Installing PHP Platforms, Servers, Databases, and PHP Where to Find PHP and More Installing PHP for Linux and Apache Some configure Options Configuring Apache php. ini Help! Summary... become a proficient PHP programmer Part IV, "Extending PHP, " examines library code, both code that you can create yourself and PEAR, a repository of library code you can include in your own projects

Ngày đăng: 25/03/2019, 15:44

w