PHP
  Home arrow PHP arrow Optimizing System Performance
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Optimizing System Performance
By: Sams Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 8
    2006-11-30


    Table of Contents:
  • Optimizing System Performance
  • Optimizing Performance
  • Database Optimizations
  • Keep Your Code Simple
  • Exam Prep Questions

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Optimizing System Performance
    ( Page 1 of 5 )

    In this second part of a two part series, you'll learn how to use debuggers and optimize performance. It is excerpted from chapter 12 of the book Zend PHP Certification, written by George Schlossnagle et al (Sams; ISBN: 0672327090).

    Logging and Debugging

    Displaying error messages to the browser is a problem from many points of view. First, you're letting your visitors know that something in your code is broken, thus shaking their confidence in the solidity of your website. Second, you're exposing yourself to potential security vulnerabilities because some of the information outputted might be used to hack into your system. Third, you're preventing yourself from finding out what error occurred so that you can fix it.

    A good solution to this problem consists of changing your php.ini setting so that the errors are not displayed to the screen, but stored in a log file. This is done by turning display_errors to off and log_errors to on, as well as setting a log file where the error messages are stored through the error_log option. You can open a shell and use tail –f to follow the PHP log.

    If you want to go a step further, you could use the set_error_handler() function to define your own error handlers and log additional information that you might find useful when trying to troubleshoot the problem.

    Naturally, you can also use the error-suppression operator @ to prevent PHP from displaying or logging the error. Although this is an easy way to solve the problem, it could lead to problems when using in production scenarios in which you do need to find out when an error occurs so that you can fix it.

    Using Debuggers

    Ultimately, not all bugs can be solved just by staring really hard at the code (although it often helps to). In some cases, you just need to "see" the program running to discover what's causing it not to perform properly. What you need is a debugger.

    A lot of debuggers exist, starting with the ancient DBG (now integrated into NuSphere's PHPEd) and progressing to APD, XDebug and the debugger that's integrated into the Zend Studio IDE. Most debuggers have the capability to set breakpoints on specific lines in your code and watch points where you can watch the global scope of your PHP variables.

    Using a debugger, you can step through each line of your application and see exactly how it flows. As such, you should definitely be familiar with one because some day you're definitely going to need one.



     
     
    >>> More PHP Articles          >>> More By Sams Publishing
     

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek