Muutke küpsiste eelistusi

PHP Cookbook [Pehme köide]

  • Formaat: Paperback / softback, 610 pages, kõrgus x laius x paksus: 233x179x32 mm, kaal: 890 g, index
  • Ilmumisaeg: 24-Dec-2002
  • Kirjastus: O'Reilly Media
  • ISBN-10: 1565926811
  • ISBN-13: 9781565926813
Teised raamatud teemal:
  • Pehme köide
  • Hind: 48,48 €*
  • * saadame teile pakkumise kasutatud raamatule, mille hind võib erineda kodulehel olevast hinnast
  • See raamat on trükist otsas, kuid me saadame teile pakkumise kasutatud raamatule.
  • Kogus:
  • Lisa ostukorvi
  • Tasuta tarne
  • Lisa soovinimekirja
  • Formaat: Paperback / softback, 610 pages, kõrgus x laius x paksus: 233x179x32 mm, kaal: 890 g, index
  • Ilmumisaeg: 24-Dec-2002
  • Kirjastus: O'Reilly Media
  • ISBN-10: 1565926811
  • ISBN-13: 9781565926813
Teised raamatud teemal:
Offers instructions for creating programs to do tasks including fetching URLs and generating bar charts using the open source scripting language, covering topics such as data types, regular expressions, encryption, and PEAR.

PHP is a simple yet powerful open source scripting language that has become a big player in web development. Over a million web sites, from large corporate sites to small personal sites, are using PHP to serve dynamic web content. PHP's broad feature set, approachable syntax, and support for different operating systems and web servers make it an ideal language for rapid web development.The PHP Cookbook is a collection of problems, solutions, and practical examples for PHP programmers. The book contains a unique and extensive collection of best practices for everyday PHP programming dilemmas. For every problem addressed in the book, there's a worked-out solution or "recipe" -- short, focused pieces of code that you can insert directly into your applications. But this book offers more than cut-and-paste code. You also get explanations of how and why the code works, so you can learn to adapt the problem-solving techniques to similar situations.The recipes in the PHP Cookbook range from simple tasks, such as sending a database query and fetching URLs, to entire programs that demonstrate complex tasks, such as printing HTML tables and generating bar charts. This book contains over 250 recipes on the following topics:

  • Working with basic data types, including strings, numbers, dates and times, and arrays
  • PHP building blocks, such as variables, functions, classes, and objects
  • Web programming, including forms, database access, and XML
  • Useful features like regular expressions, encryption and security, graphics, internationalization and localization, and Internet services
  • Working with files and directories
  • Command-line PHP and PHP-GTK
  • PEAR, the PHP Extension and Application Repository
This book contains an impressive collection of useful code for PHP programmers, from novices to advanced practitioners. Instead of poking around mailing lists, online documentation, and other sources, you can rely on the PHP Cookbook to provide quick solutions to common problems, so you can spend your time on those out-of-the-ordinary problems specific to your application.

Arvustused

"This book is absolutely packed with quick solutions to common obstacles or ideas in PHP. The chapters on security are worth their weight in gold, as you'll learn how to properly protect your site against unauthorised use." .NET, February 2004

Preface xv
Strings
1(23)
Accessing Substrings
3(2)
Replacing Substrings
5(1)
Processing a String One Character at a Time
6(1)
Reversing a String by Word or Character
7(1)
Expanding and Compressing Tabs
8(2)
Controlling Case
10(2)
Interpolating Functions and Expressions Within Strings
12(1)
Trimming Blanks from a String
13(1)
Parsing Comma-Separated Data
14(1)
Parsing Fixed-Width Delimited Data
15(2)
Taking Strings Apart
17(3)
Wrapping Text at a Certain Line Length
20(1)
Storing Binary Data in Strings
21(3)
Numbers
24(18)
Checking Whether a String Contains a Valid Number
25(1)
Comparing Floating-Point Numbers
26(1)
Rounding Floating-Point Numbers
27(1)
Operating on a Series of Integers
28(1)
Generating Random Numbers Within a Range
29(2)
Generating Biased Random Numbers
31(1)
Taking Logarithms
32(1)
Calculating Exponents
32(1)
Formatting Numbers
33(1)
Printing Correct Plurals
34(2)
Calculating Trigonometric Functions
36(1)
Doing Trigonometry in Degrees, not Radians
37(1)
Handling Very Large or Very Small Numbers
37(2)
Converting Between Bases
39(1)
Calculating Using Numbers in Bases Other Than Decimal
40(2)
Dates and Times
42(33)
Finding the Current Date and Time
43(3)
Converting Time and Date Parts to an Epoch Timestamp
46(1)
Converting an Epoch Timestamp to Time and Date Parts
47(1)
Printing a Date or Time in a Specified Format
48(4)
Finding the Difference of Two Dates
52(2)
Finding the Difference of Two Dates with Julian Days
54(1)
Finding the Day in a Week, Month, Year, or the Week Number in a Year
55(2)
Validating a Date
57(2)
Parsing Dates and Times from Strings
59(2)
Adding to or Subtracting from a Date
61(1)
Calculating Time with Time Zones
62(5)
Accounting for Daylight Saving Time
67(1)
Generating a High-Precision Time
68(1)
Generating Time Ranges
69(1)
Using Non-Gregorian Calendars
70(1)
Program: Calendar
71(4)
Arrays
75(42)
Specifying an Array Not Beginning at Element 0
78(1)
Storing Multiple Elements per Key in an Array
79(1)
Initializing an Array to a Range of Integers
80(1)
Iterating Through an Array
81(2)
Deleting Elements from an Array
83(2)
Changing Array Size
85(2)
Appending One Array to Another
87(2)
Turning an Array into a String
89(2)
Printing an Array with Commas
91(1)
Checking if a Key Is in an Array
92(1)
Checking if an Element Is in an Array
92(2)
Finding the Position of an Element in an Array
94(1)
Finding Elements That Pass a Certain Test
95(1)
Finding the Largest or Smallest Valued Element in an Array
96(1)
Reversing an Array
97(1)
Sorting an Array
98(1)
Sorting an Array by a Computable Field
99(2)
Sorting Multiple Arrays
101(2)
Sorting an Array Using a Method Instead of a Function
103(1)
Randomizing an Array
104(1)
Shuffling a Deck of Cards
105(1)
Removing Duplicate Elements from an Array
106(1)
Finding the Union, Intersection, or Difference of Two Arrays
107(2)
Finding All Element Combinations of an Array
109(2)
Finding All Permutations of an Array
111(3)
Program: Printing an Array in a Horizontally Columned HTML Table
114(3)
Variables
117(14)
Avoiding == Versus = Confusion
118(1)
Establishing a Default Value
119(1)
Exchanging Values Without Using Temporary Variables
120(1)
Creating a Dynamic Variable Name
120(2)
Using Static Variables
122(1)
Sharing Variables Between Processes
123(2)
Encapsulating Complex Data Types as a String
125(2)
Dumping Variable Contents as Strings
127(4)
Functions
131(17)
Accessing Function Parameters
132(1)
Setting Default Values for Function Parameters
133(2)
Passing Values by Reference
135(1)
Using Named Parameters
136(1)
Creating Functions That Take a Variable Number of Arguments
137(3)
Returning Values by Reference
140(1)
Returning More Than One Value
140(2)
Skipping Selected Return Values
142(1)
Returning Failure
143(1)
Calling Variable Functions
144(1)
Accessing a Global Variable Inside a Function
145(2)
Creating Dynamic Functions
147(1)
Classes and Objects
148(20)
Instantiating Objects
152(1)
Defining Object Constructors
153(1)
Destroying an Object
154(1)
Cloning Objects
154(1)
Assigning Object References
155(1)
Calling Methods on an Object Returned by Another Method
156(1)
Accessing Overridden Methods
157(2)
Using Property Overloading
159(1)
Using Method Polymorphism
160(3)
Finding the Methods and Properties of an Object
163(1)
Adding Properties to a Base Object
164(1)
Creating a Class Dynamically
165(1)
Instantiating an Object Dynamically
166(2)
Web Basics
168(48)
Setting Cookies
169(2)
Reading Cookie Values
171(1)
Deleting Cookies
171(1)
Redirecting to a Different Location
172(1)
Using Session Tracking
173(2)
Storing Sessions in a Database
175(4)
Detecting Different Browsers
179(1)
Building a GET Query String
180(2)
Using HTTP Basic Authentication
182(2)
Using Cookie Authentication
184(3)
Flushing Output to the Browser
187(1)
Buffering Output to the Browser
187(2)
Compressing Web Output with gzip
189(1)
Hiding Error Messages from Users
190(1)
Tuning Error Handling
191(2)
Using a Custom Error Handler
193(1)
Logging Errors
194(1)
Eliminating ``headers already sent'' Errors
195(2)
Logging Debugging Information
197(2)
Reading Environment Variables
199(1)
Setting Environment Variables
200(1)
Reading Configuration Variables
201(1)
Setting Configuration Variables
202(1)
Communicating Within Apache
203(1)
Profiling Code
204(4)
Program: Website Account (De)activator
208(2)
Program: Abusive User Checker
210(6)
Forms
216(22)
Processing Form Input
218(1)
Validating Form Input
219(2)
Working with Multipage Forms
221(3)
Redisplaying Forms with Preserved Information and Error Messages
224(3)
Guarding Against Multiple Submission of the Same Form
227(2)
Processing Uploaded Files
229(2)
Securing PHP's Form Processing
231(2)
Escaping Control Characters from User Data
233(1)
Handling Remote Variables with Periods in Their Names
234(1)
Using Form Elements with Multiple Options
235(1)
Creating Dropdown Menus Based on the Current Date
236(2)
Database Access
238(43)
Using Text-File Databases
243(1)
Using DBM Databases
244(4)
Connecting to a SQL Database
248(2)
Querying a SQL Database
250(2)
Retrieving Rows Without a Loop
252(2)
Modifying Data in a SQL Database
254(1)
Repeating Queries Efficiently
255(2)
Finding the Number of Rows Returned by a Query
257(1)
Escaping Quotes
258(1)
Logging Debugging Information and Errors
259(3)
Assigning Unique ID Values Automatically
262(1)
Building Queries Programmatically
263(4)
Making Paginated Links for a Series of Records
267(5)
Caching Queries and Results
272(2)
Program: Storing a Threaded Message Board
274(7)
Web Automation
281(28)
Fetching a URL with the GET Method
283(2)
Fetching a URL with the POST Method
285(2)
Fetching a URL with Cookies
287(2)
Fetching a URL with Headers
289(1)
Fetching an HTTPS URL
290(1)
Debugging the Raw HTTP Exchange
290(3)
Marking Up a Web Page
293(2)
Extracting Links from an HTML File
295(1)
Converting ASCII to HTML
296(1)
Converting HTML to ASCII
297(1)
Removing HTML and PHP Tags
298(1)
Using Smarty Templates
299(2)
Parsing a Web Server Log File
301(2)
Program: Finding Stale Links
303(2)
Program: Finding Fresh Links
305(4)
XML
309(34)
Generating XML Manually
311(2)
Generating XML with the DOM
313(3)
Parsing XML with the DOM
316(3)
Parsing XML with SAX
319(4)
Transforming XML with XSLT
323(3)
Sending XML-RPC Requests
326(3)
Receiving XML-RPC Requests
329(4)
Sending SOAP Requests
333(3)
Receiving SOAP Requests
336(2)
Exchanging Data with WDDX
338(2)
Reading RSS Feeds
340(3)
Regular Expressions
343(18)
Switching From ereg to preg
346(2)
Matching Words
348(1)
Finding the nth Occurrence of a Match
349(1)
Choosing Greedy or Nongreedy Matches
350(2)
Matching a Valid Email Address
352(3)
Finding All Lines in a File That Match a Pattern
355(1)
Capturing Text Inside HTML Tags
355(2)
Escaping Special Characters in a Regular Expression
357(2)
Reading Records with a Pattern Separator
359(2)
Encryption and Security
361(22)
Keeping Passwords Out of Your Site Files
362(1)
Obscuring Data with Encoding
363(1)
Verifying Data with Hashes
364(2)
Storing Passwords
366(1)
Checking Password Strength
367(2)
Dealing with Lost Passwords
369(2)
Encrypting and Decrypting Data
371(4)
Storing Encrypted Data in a File or Database
375(3)
Sharing Encrypted Data with Another Web Site
378(2)
Detecting SSL
380(1)
Encrypting Email with GPG
381(2)
Graphics
383(25)
Drawing Lines, Rectangles, and Polygons
386(2)
Drawing Arcs, Ellipses, and Circles
388(2)
Drawing with Patterned Lines
390(1)
Drawing Text
391(3)
Drawing Centered Text
394(4)
Building Dynamic Images
398(3)
Getting and Setting a Transparent Color
401(1)
Serving Images Securely
402(1)
Program: Generating Bar Charts from Poll Results
403(5)
Internationalization and Localization
408(18)
Listing Available Locales
409(1)
Using a Particular Locale
410(1)
Setting the Default Locale
411(1)
Localizing Text Messages
412(3)
Localizing Dates and Times
415(1)
Localizing Currency Values
416(3)
Localizing Images
419(1)
Localizing Included Files
420(1)
Managing Localization Resources
421(2)
Using gettext
423(1)
Reading or Writing Unicode Characters
424(2)
Internet Services
426(28)
Sending Mail
427(3)
Sending MIME Mail
430(2)
Reading Mail with IMAP or POP3
432(3)
Posting Messages to Usenet Newsgroups
435(2)
Reading Usenet News Messages
437(5)
Getting and Putting Files with FTP
442(2)
Looking Up Addresses with LDAP
444(2)
Using LDAP for User Authentication
446(2)
Performing DNS Lookups
448(2)
Checking if a Host Is Alive
450(1)
Getting Information About a Domain Name
451(3)
Files
454(39)
Creating or Opening a Local File
457(2)
Creating a Temporary File
459(1)
Opening a Remote File
460(1)
Reading from Standard Input
460(1)
Reading a File into a String
461(2)
Counting Lines, Paragraphs, or Records in a File
463(2)
Processing Every Word in a File
465(2)
Reading a Particular Line in a File
467(1)
Processing a File Backward by Line or Paragraph
468(1)
Picking a Random Line from a File
468(1)
Randomizing All Lines in a File
469(1)
Processing Variable Length Text Fields
470(1)
Reading Configuration Files
471(3)
Reading from or Writing to a Specific Location in a File
474(1)
Removing the Last Line of a File
475(2)
Modifying a File in Place Without a Temporary File
477(2)
Flushing Output to a File
479(1)
Writing to Standard Output
479(1)
Writing to Many Filehandles Simultaneously
480(1)
Escaping Shell Metacharacters
481(2)
Passing Input to a Program
483(1)
Reading Standard Output from a Program
484(1)
Reading Standard Error from a Program
485(1)
Locking a File
486(3)
Reading and Writing Compressed Files
489(1)
Program: Unzip
490(3)
Directories
493(25)
Getting and Setting File Timestamps
496(1)
Getting File Information
497(1)
Changing File Permissions or Ownership
498(1)
Splitting a Filename into Its Component Parts
499(2)
Deleting a File
501(1)
Copying or Moving a File
501(1)
Processing All Files in a Directory
502(1)
Getting a List of Filenames Matching a Pattern
503(1)
Processing All Files in a Directory
504(3)
Making New Directories
507(1)
Removing a Directory and Its Contents
508(1)
Program: Web Server Directory Listing
509(5)
Program: Site Search
514(4)
Client-Side PHP
518(34)
Parsing Program Arguments
522(1)
Parsing Program Arguments with getopt
523(4)
Reading from the Keyboard
527(1)
Reading Passwords
528(3)
Displaying a GUI Widget in a Window
531(1)
Displaying Multiple GUI Widgets in a Window
532(3)
Responding to User Actions
535(2)
Displaying Menus
537(3)
Program: Command Shell
540(3)
Program: Displaying Weather Conditions
543(9)
PEAR
552(17)
Using the PEAR Package Manager
554(2)
Finding PEAR Packages
556(2)
Finding Information About a Package
558(1)
Installing PEAR Packages
559(2)
Installing PECL Packages
561(1)
Upgrading PEAR Packages
562(2)
Uninstalling PEAR Packages
564(1)
Documenting Classes with PHPDoc
564(5)
Index 569
David Sklar is an independent consultant in New York City. He was co-founder and Chief Technology Officer of two companies: Student.Com and TVGrid.Com. Mr. Sklar holds a BS in Computer Science from Yale University. Adam Trachtenberg lives in New York City and is currently working on his MBA from Columbia Business School. Before returning to school, he co-founded two companies: Student.Com and TVGrid.Com, where he served both as Vice President for Development. Mr. Trachtenberg also has a BA in Mathematics from Columbia University.