The PHP Anthology: 101 Essential Tips, Tricks & Hacks

The PHP Anthology: 101 Essential Tips, Tricks & Hacks

Davey Shafik

Language: English

Pages: 542

ISBN: 0975841998

Format: PDF / Kindle (mobi) / ePub


The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition is a collection of powerful PHP 5 solutions to the most common programming problems.

Featuring best-practice code and a commonsense approach to development, this book includes coverage of:

  • Manage errors gracefully.
  • Build functional forms, tables, and SEO-friendly URLs.
  • Reduce load time with client- and server-side caching.
  • Produce and utilize web services with XML.
  • Secure your site using access control systems.
  • Easily work with files, emails, and images.
  • And much more

    The question and answer format will allow you to to quickly find and reference any of the 101 solutions, saving you hours of Internet research or painful trial & error. All solutions are fully explained and the ready-to-use code is available for download.

    From the Publisher

    "A comprehensive collection of ready-to-use PHP solutions!"

    • Over 100 easy-to understand PHP tips, tricks and hacks.
    • Save hours of time with "copy and paste" ready code.
    • All solutions are fully explained by five PHP gurus.
    • Learn the very latest object oriented PHP techniques.
    • And so much more...

    Each chapter of this book is laid out in a problem-solution format. We'll start with a common PHP problem that you may face, and then provide a concise solution to that problem. In some cases, when the topic warrants it, we'll give you a brief discussion of the solution to provide context.

    The chapters are grouped to cover the major areas of PHP. Inside, you'll find solutions to the most common challenges that PHP developers face.

    What Slashdot.org Says

    "The chapters on error handling and access control are alone worth the price of the book"

  • The art and theory of dynamic programming, Volume 130 (Mathematics in Science and Engineering)

    Programming Language Pragmatics (3rd Edition)

    Haptic Interaction with Deformable Objects: Modelling VR Systems for Textiles (Springer Series on Touch and Haptic Systems)

    Google Secrets

     

     

     

     

     

     

     

     

     

     

     

     

     

    File on a remote server? . . . . . . . . . . . . . . . . . . . . . . . 166 How do I use FTP from PHP? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 How do I manage file downloads with PHP? . . . . . . . . . . . . . . . . . . . . . . 170 How do I create compressed ZIP/TAR files with PHP? . . . . . . . . . . . . . . 172 How do I work with files using the Standard PHP Library in PHP 5? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    . . . . . . . . . . . . . . . . . . . . . . 235 Chapter 9 Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . 237 What error levels does PHP report? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 What built-in settings does PHP offer for error handling? . . . . . . . . . . 239 How can I trigger PHP errors? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 How do I implement a custom error handler with PHP? . . . . . . . . . . . . 242.

    Shows the frozen form. Download at Boykma.Com Forms, Tables, and Pretty URLs Figure 5.2. The registration form with validation mechanisms Download at Boykma.Com 123 124 The PHP Anthology Figure 5.3. The frozen registration form Now that we’ve validated the data submitted by our users, we need to accept and store it. Let’s look at an alternative to the above example, in which we extract the form data and insert it into our database. To extract the submitted data from the form, we.

    Access information about a local file? PHP comes with a range of functions to help you obtain information about a file. Solution In the following example, we use a number of handy functions: ■ file_exists, to check whether the file exists ■ is_file, to check the file is indeed a file and not a directory ■ is_readable, to check whether the file can be read ■ is_writable to check whether the file can be written to ■ filemtime to check the date and time at which the file the file was last.

    Modified ■ fileatime to find the date and time the file at which was last accessed ■ filesize to check the file’s size We also wrap the result in some custom code to make it more readable: fileInfo.php (excerpt) = 1073741824) { $size = number_format(($size $unit = 'GB'; } else if ($size >= 1048576) { $size = number_format(($size $unit = 'MB'; } else if ($size >= 1024) { $size = number_format(($size $unit = 'KB'; }.

    Download sample

    Download