作者:empty 页数:465 出版社:empty |
O2004by Thomson Course Technology PTR All rights reser wed.Nopart of this book maybe reproduced or transmitted in any for mar byany means electronic or mechanical.including photocopying.recording.or by any into rmation storage or retrieval system without writtenper miss a on from Thomson Course Technology PTR.c xcept for thenc us inafbnerquatatnsinareviwThe Thomson Course Technology PIR logo and related trade dress aretrademarks of Thomson Course Technology PTR and may not be usedwith our wnt ten permissionMicrosoft, Windows, InternetExplorer.Notepad, VBScript.ActiveX.and FrontPage are either Teg istered trademarks or trademarks ofMicrosoft Corporation im the United States and J or other countriesNetscape is are gst ered trademark of Netscape Communications Corpo tation in the US and other countries.PHP5iscopyighte 2001-2004 The PHP Group.MySQL is a registeredtrademark of MySQL A Bin the United States.the European Union andother countries.
All other trademarks are the property of the irrespective owners.Important.Thomson Course Technology PTR can not provide softwaresupport.Please contact the appropriate software manu tac turerstechnical support line or Website for assistanceThomson Course Technology PIR and the author ha we attempted throug lrout this book to distinguish prop net ary trademarks from de seri pawterms by following the capitalization style used by the manufacturer.Information contained in this book has been obtained by ThomsonCourse Technology PIR trom sources believed to be rehab le.However.because of the possibily of humans or mechanical error by oursources.Tho is on Course Technology PTR.or others, the Publisherdaes noc guarantee the accuracy.adequacy, or completeness of anyinto rmation and is not responsible for any errors or omissions or theresults ab tained from use of such an ormation Read ets should bejaticularly an are of the tact that the internet is an everchanging enti ySome facts may have changed since this book went to press,Educationalfaclities.companies, and a rganizations interested in mul-tiple copies or licensing of this book should contact the publisher forquant discount informatin.Training manuals CD-ROMs.and portions of this book are also available individually or can be tailored forspecific ne cds.
AcknowledgmentsFirst I thank Him from whom all flows.Heather, you always work harder on these books than I do.Thankyoufor your love and your support.Thankyou Elizabeth, Matthew, andJacob for understanding why Daddy was typing all the time.Thanks to the OpenSource community for creating great free software like PHPand MySQL.Also, thanks to the phpMyAdmin team and the SQLite team fordeveloping such terrific software and making it freely availableThankyou, Stacy Hi quet.for your continued support and encouragement on thisand other projects.Thanks, Scott Harris.You did a great job of juggling all those balls around.Thanks to Tonya Cupp for drastically improving the readability of the manuscriptArlie Hartman, thankyou for technical editing and for putting together the CD-ROM.Thanks to J.Wynia(www.phpgeek.com) for technical editing.Thanks also to Jasonfor use of PHPTriad on the CD-ROM.Special thanks to those who worked on the first edition.Your hard work is thefoundation for something even better.Thankyou to the many members of the Premier/Course team who worked onthis book.A huge thanks goestomyCSCIN399andN 452 Server-Side Web Developmentclasses and the many people who sent in comments and advice from the first edi-tion.Thankyou for being patient with my manuscript.for helping me spot manyerrors, and for providing invaluable advice.I learned as much from you as youdid from me-About the AuthorSince 1995hehasbeena full-time lecturer in the Computer Science Departmentof Indiana University/Purdue University-Indianapolis, where he manages theStreaming MediaLab and teaches classes in several programming languages.Hisprimary interests are PHP.Java, Microsoft languages.Perl.JavaScript, Web Data,virtual reality.portable devices, and streaming media.He has written numerousbooks on these and other technology topics.ndy Harris began his teaching career as a high-school special educationteacher.During that time, he taught himself enough computing to dopart-time computer consulting and database work.He began teachingcomputing at the university level in the late1980sasa part-time job.
Conditions and Functions
Cascading StyleSheets
Alternative DataSource
Introduction.
Chapter l:Exploring the PHP Environment
Chapter2:UsingVariablesandInput
Chapter 3:Controlling Your Code with
chapter4:LoopsandArrays
Chapter5:BetterArraysandStringHandling
Chapter b:Working with Files
Chapter7:WritingProgramswithObjects
Chapter A:XML and Content Management Systems . 271
Chapter9:UsingMySQLtoCreateDatabases.299
Chapter LD:Connecting to Databases within PHP. 335
Chapter ll:Data Normalization.359
chapterL2:BuildingaThree-TieredDataApplication.383
Appendix A:Reviewing HTML and
Appendix8:UsingSQLiteasan
Chapter l:Exploring the PHP Environment
Chapter2:UsingVariablesandInput
Chapter 3:
Introducing the Tip of the Day Program.
Programming on the WebServer.
Installing PHP and Apache.
Using an Existing Server.
Installing Your Own Development Environment.
Installing Apache.
Installing Apache Files.
Testing Your Server.
Starting Apache as a Service.
Configuring Apache.
Running Your Local Server.
Installing PHP.
Downloading the PHP Program
Telling Apache about PHP.
Adding PHP to Your Pages.
Adding PHP Commands to an HTML Page
Examining the Results.
Configuring Your Version of PHP.
SafeMode.
Register Globals,
Windows Extensions.
Creating the Tip of the Day Program, .
Summary.
Introducing the Story Program.
Using Variables in Your Scripts.
Introducing the Hi Jacob Program.
Creating a String Variable.
Printing a Variable's Value.
Using the Semicolon to End a Line.
Using Variables for More-Complex Pages.
Building the Row Your Boat Page.
Creating Multi-Line Strings.
Working with Numeric Variables.
Making the Three Plus Five Program,
Assigning Numeric Values.
Using Mathematical Operators.
Creating a Form to Ask a Question.
Building an HTML Page with a Form.
Setting the Action Attribute to a Script File.“t”
Writing a Script to Retrieve the Data.
Sending Data without a Form.
Understanding the get Method.
Using a URL to Embed Form Data.
Working with Multiple Field Queries.
Reading Input from Other Form Elements.
Introducing the border Maker Program, ,
Building the border Maker.html Page.
Reading the Form Elements.,
Returning to the Story Program.
Designing the Story.
Building the HTML Page.
Checking the Form.
Building the Final Story.
Controlling Your Code with
Conditions and Functions
Examining the Petals Around the Rose Game.
Creating a Random Number.
Viewing the Roll Em Program.5z
Printing a Corresponding Image.58
Using the if Statement to Control Program Flow.58
Introducing the Ace Program.59
Creating a Condition.60
Exploring Comparison Operators, .62
Creating an if Statement.62
Working with Negative Results.63
Demonstrating the Ace or Not Program.64
Using the else Clause.65
Working with Multiple Values.
Writing the Binary Dice Program.
Using Multiple elseif Clauses.
Using the switch Structure to Simpli y Programming . 69
Building the Switch Dice Program.-.69
Using the switch Structure.71
Combining a Form and Its Results.71
Responding to Checkboxes.74
Using Functions to Encapsulate Parts of the Program . 77
Examining the This OldMan Program.77
Creating New Functions.79
Using Parameters and Function Values.80
Examining the Param.php Program.*.80
Looking at Encapsulation in the Main Code Body . 82
Returning a Value:The chorus() Function.83
Accepting a Parameter in the verse(Function.84
Managing Variable Scope.-.85
Looking at the Scope Demo.86
Returning to the Petals Game.88
Starting HTML.-.88
Main Body Code.-.89
The print Greeting() Function.89
The print Dice() Function.90
The show Diel) Function.91
The calc Num Petals Function.-.92
The print Form() Function.93
The Ending HTML Code.94
Summary.94
Introducing the Poker Dice Program.96
Counting with the for Loop.96
Intial i in gaS entry Variable.98
Setting a Condition to Finish the Loop.99
Changing the Sentry Variable.99
Building the Loop.100
Modifying the for Loop.100
Counting by Fives.100
Counting Backwards, .102
Using awhile Loop.103
Repeating Code with awhile Loop.103
Recognizing Endless Loops.105
Building a Well-Behaved Loop.106
Working with Basic Arrays.107
Generating a Basic Array.109
Using a Loop to Examine an Array's Contents.109
Using the array O Function toP reload an Array, .110
Detecting the Sizeof an Array.170
Improving This OldMan with Arrays and Loops.111
Building the Place Array.113
Writing Out the Lyrics.113
Keeping Persistent Data.114
Counting with Form Fields.174
Storing Data in the TextBox.116
Using a Hidden Field for Persistence.117
Writing the Poker Dice Program.177
Setting Up the HTML-.117
Building the Main Code Body.118
Making the roll Dice() Function.119
Creating the evaluate l) Function.123
Printing the Results.129
Summary.130
Introducing the WordSearch Program Creator.134
Using the for each Loop to Work with an Array.135
Introducing the for each.php Program.,.136
Creating an Associative Array.137
Examining the assoc.php Program.138
Building an Associative Array.138
Building an Associative Array
Using for each wth Assoc