Archive for October, 2006

PHP vs. Other Scripting Languages For those who

Tuesday, October 31st, 2006

PHP vs. Other Scripting Languages For those who have migrated from other scripting languages, we have detailed a section on why you just made the right choice. PHP vs. ASP ASP (Active Server Pages) is Microsoft’s proprietary scripting “language”. Loosely speaking, ASP isn’t a language, but a scripting extension of Visual Basic. For this reason, ASP is relatively easy to pick up for anyone who is familiar with Visual Basic. Disadvantages? For one, ASP is generally slower than PHP. ASP is a fundamental user of COM-based architecture. So, when an ASP programmer accesses the database and writes to the client, they’re calling upon the COM strictures of another NT service or an OS layer to assist. This COM overhead can add up and results in average performance for anything more than medium-traffic simple page delivery. Also, ASP isn’t exactly ready to port and integrate with GNU tools and open source environments or servers. Since it’s a proprietary system of Microsoft, it is mostly used on their Internet Information Server (IIS), which limits common adoption of ASP to Windows 32 bit systems where it comes as a free piece of code to most server customers. There are versions for UNIX (see ChilliSoft ASP) and several ASP interpreters for other systems and web servers, but the cost, together with performance, then becomes a concern. A solution to this problem might be to use the asp2phpprogram (http://asp2php.naken.cc/), which will convert ASP to PHP. ASP.NET is a very different animal though. The future may bring some highly significant performance and scaling improvements in ASP. This is achieved by a further leverage of the .NET/COM architecture and management environment. However, the real advantages may only be available to those that spend heavily on various associated servers. PHP vs. Cold Fusion PHP runs on virtually every platform; Cold Fusion is only available on Win32, Solaris, Linux, and HP/UX. PHP initially requires more programming knowledge in contrast with Cold Fusion, which has a refined IDE and simpler language constructs. PHP is less resource intensive. PHP vs. Perl Since PHP was designed specifically for the Web, it has the upper hand on Perl in this area, since Perl was designed for myriad applications (and consequently looks the part). The format and syntax of Perl can make a Perl script hard to read and modify later when updates are needed. Though Perl has been around for quite some time (it was developed in the late 1980s), and is widely supported, it has grown into a complex structure of additions and extensions and is simply just too much. PHP has a less confusing format without losing its flexible nature. PHP is easier to integrate into existing HTML and offers similar functionality to Perl, but with so much more grace. PHP vs. Java PHP is simpler to use than Java and makes it easier to architect web applications while also gaining similar advantages of flexibility and scalability. Using PHP doesn’t require 5 years of software engineering experience to create simple, dynamic pages and can be used by savvy, but inexperienced, computer programmers. Java is often expensive too, as most companies end up having a stand alone box to run Java Enterprise and use Oracle and other expensive software. Having said all that, PHP still has to grow and in that it’s not as portable or doesn’t have some of the nice features like object pooling or database mapping as in Java. These issues are being addressed in the Zend 2.0 engine design considerations. Page 21
Note: If you are looking for inexpensive but high quality provider to host and run your jsp application check Astra jsp hosting services

PHP Evolution If you’re new to PHP, here’s

Tuesday, October 31st, 2006

PHP Evolution If you’re new to PHP, here’s a quick run down on where it’s been, where it is now, and where it’s going. PHP Past We will tersely summarize the history of PHP here, but we urge readers interested in the historical aspects of PHP development to review the introductory PHP presentations at http://conf.php.net/ or read the Brief History section in the PHP/FI 2 manual at http://php.net/docs.php. Rasmus Lerdorf conceived the idea of PHP in the fall of 1994. Version 1 of the language was implemented in early 1995 and was embraced by a handful of users, following which Version 2 was released later the same year. Versions 3 and 4 followed in 1997 and 2000 respectively. PHP Present As of the time of writing, PHP usage is growing at a rate of 15% each month, and is in use on at least seven million domains (Source: Netcraft Survey), which is about 20% of all the domains registered so far. This is a significant chunk of the market, given that these figures do not account for the multitude of installations that run on intranets and private development servers. PHP runs on 7 major platforms (stable), 10 server interfaces (stable), supports 40 stable extensions (and about as many experimental ones), and offers support to over 20 databases. These figures are testimony to the fact that PHP has grown to its current popularity based on its power and ease of use. PHP in the Ring Before we dive into cursory details of the advantages of PHP4 over PHP3, we would like to thank thousands of our readers who embraced Professional PHP Programming from Wrox (ISBN 1-861002-96-3) published in the winter of 1999. We sincerely hope that this blog will be a professional follow-up read for all the developments that have happened in the PHP world since. With PHP3, the parsing and compiling of PHP code happened simultaneously, thus reducing the basic start-up time for execution to begin. This was the main reason behind the high performance of simple scripts. Sadly, when it was burdened with the onus of handling complex scripts, there arose a redundancy in terms of parsing parts of the code over and over again, as with loops and repetitive function calls. The core engine was at fault, and so it became obvious that this was the first area to attack in the race for performance, thus instantiating the development of PHP4. At this point it would be a dereliction in our duties if we failed to mention the massive contribution from Zend to the world of PHP development. We urge you to visit http://www.zend.com/zend/whatsnew.php for details on the new features in PHP4. PHP Future The PHP4 scripting engine is a second revision of the PHP3 scripting engine, and provides more obvious infrastructure and services to the function modules, and implements the language syntax. This revised version is largely based on the same parsing rules as the PHP3 engine, thus providing good backward compatibility and migration path from PHP3 to PHP4. But the downside is the limited scope of language-level improvements, to the PHP3 mindset. With feedback from a multitude of PHP developers, Zend Technologies Ltd has embarked on a revision of the Zend Engine that will incorporate new features, improve existing ones, and provide solutions to some of the most difficult problems that PHP developers experience today. We urge you to add http://www.zend.com/zend/future.php to your list of favorites, and also subscribe to the Zend 2.0 weekly chronicle notification service at http://www.zend.com/zend/zengine/, if you are closely monitoring the PHP roadmap. Page 20
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision tomcat hosting services

Chapter 1: PHP Roadmap We expect our readers

Tuesday, October 31st, 2006

Chapter 1: PHP Roadmap We expect our readers to have a more than firm handle on what PHP is, but for completeness-sake: PHP (a recursive acronym of PHP: Hypertext Preprocessor) is an open source, server-side web-scripting language for creating dynamic web pages. Outside of it being browser independent, it offers a simple and universal cross-platform solution for e-commerce, and complex web and database-driven applications. Why PHP? PHP has: . A low, smooth learning curve. . Broad functionality for databases, strings, network connectivity, file system support, Java, COM, XML, CORBA, WDDX, and Macromedia Flash. . Platform compatibility with UNIX (all variants), Win32 (NT/95/98/2000), QNX, MacOS (WebTen), OSX, OS/2, and BeOS. . Server compatibility for Apache module (UNIX, Win32), CGI/FastCGI, thttpd, fhttpd, phttpd, ISAPI (IIS, Zeus), NSAPI (Netscape iPlanet), Java servlet engines, AOLServer, and Roxen/Caudium module. . A rapid development cycle. New versions with bug fixes, additional functionality, and other improvements are released every few months. . A vibrant and supportive community. Code examples and free code abound. The PHP group has done an excellent job of providing new users with resources and support. . Easy extensibility. We can easily roll out our own extensions to the language. . A simple syntax that resembles C. It’s easy for experienced C, C++, Perl, and shell coders to pick up PHP. Plus, it’s open source, and it’s free. Page 19
Note: If you are looking for cheap and quality provider to host and run your java application check Astra java hosting services

http://forums.apress.com For author and peer discussion, join the

Tuesday, October 31st, 2006

http://forums.apress.com For author and peer discussion, join the Apress discussion groups. If you post a query to our forums, you can be confident that many Apress authors, editors, and industry experts are examining it. At http://forums.apress.com you will find a number of different lists that will help you, not only while you read this blog, but also as you develop your own applications. To sign up for the Apress forums, go to http://forums.apress.com and select the New User link. Page 18

Hint: If you are looking for very good and affordable webspace to host and run your j2ee hosting application check Virtualwebstudio j2ee web hosting services

Errata We’ve made every effort to make sure

Tuesday, October 31st, 2006

Errata We’ve made every effort to make sure that there are no errors in the text or in the code. However, no one is perfect and mistakes do occur. If you find an error in one of our books, like a spelling mistake or a faulty piece of code, we would be very grateful for feedback. By sending in errata you may save another reader hours of frustration, and of course, you will be helping us provide even higher quality information. To find known errata and submit new errata, simply go to the appropriate book page on the Apress website at http://www.apress.com. Page 17
Note: If you are looking for cheapest and affordable webspace to host and run your servlet application check Astra servlet hosting services

How to Download the Sample Code for the

Tuesday, October 31st, 2006

How to Download the Sample Code for the Book When you log on to the Apress site, http://www.apress.com/, simply locate the title through our search facility or by using one of the title lists. Then click on the Source Code link on the book’s detail page and you can obtain all the source code. The files that are available for download from our site have been archived using WinZip. When you have saved the attachments to a folder on your hard-drive, you need to extract the files using a decompression program such as WinZip or PKUnzip. When you extract the files, the code is usually extracted into chapter folders. Page 16
Note: If you are looking for cheapest and affordable webspace to host and run your servlet application check Astra servlet hosting services

Customer Support We always value hearing from our

Tuesday, October 31st, 2006

Customer Support We always value hearing from our readers, and we want to know what you think about this blog: what you liked, what you didn’t like, and what you think we can do better next time. You can send us your comments by e-mailingsupport@apress.com. Please be sure to mention the book’s ISBN and title in your message. Page 15

Hint: This post is supported by Gama web hosting hrvatska services

Conventions To help you get the most from

Tuesday, October 31st, 2006

Conventions To help you get the most from the text and keep track of what’s happening, we’ve used a number of conventions throughout the book. For instance: Import ant These boxes hold important, not-to-be forgotten information, which is directly relevant to the surrounding text. Note While this background style is used for asides to the current discussion. As for styles in the text: . When we introduce them, we highlight important words . We show keyboard strokes like this: Ctrl-A . We show filenames and code within the text like so: echo() . Text on user interfaces and URLs are shown as: Menu We present code in three different ways. Definitions of functions and properties are shown as follows: int phpinfo([int what]) Example code is shown: In our code examples, the code foreground style shows new, important, pertinent code while code background shows code that is less important in the present context, or has been seen before. Page 14
Note: If you are looking for inexpensive but high quality provider to host and run your jsp application check Astra jsp hosting services

What You Need to Use this blog For

Tuesday, October 31st, 2006

What You Need to Use this blog For server-side programming, you will need a web server on your machine. This can be IIS or Apache on a Windows platform, or Apache or Xitami for other operating systems. For the client, you have a free choice. PHP is effective both on Internet Explorer and Netscape, as well as the other web browsers available today. To run all the code in this blog, you should have access to a relational database. Your choice for this is quite wide; we have chosen to keep MySQL as the underlying database theme. For PostgreSQL and ODBC aficionados we have also included detailed coverage on the same. For programming itself, you need a good text editor, like Notepad, vi, or Emacs. Scripting pages are simply text files, often written embedded within the markup language that makes up the web page. Page 13
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision tomcat hosting services

multi-tiered architecture, and a brand new approach using

Tuesday, October 31st, 2006

multi-tiered architecture, and a brand new approach using XML. o Chapter 16 is a case study that uses the knowledge absorbed in the previous chapter. It steps through the complete software development lifecycle of a shopping cart application for mobile devices (using WML). o Chapter 17 introduces the power of a relational database to serve content for the PHP- driven application. It also examines using PHP’s MySQL functions, building an online library application with MySQL as the back-end. Finally it looks at creating a customized database abstraction layer. o Chapter 18 looks into adding PostgreSQL support to PHP and the ways in which the PostgreSQL database can be accessed by the scripting language. We also rewrite Chapter 17’s data-driven application using PostgreSQL, and extend the previous chapter’s database abstraction layer. o Chapter 19 attempts to closely pack an overview of ODBC in with installation instructions, tips and tricks that will save us time (or get us out of trouble), and examples of how to use ODBC in real world situations. o Chapter 20 examines the usage of PHP as a command line script interpreter and examines a simple interactive script in the form of a small number guessing game. Finally it looks at PHP-GTK, the PHP extension that allows client-side, cross-platform GUI application programming. We also build a GTK interface to the application that we built in the previous 3 chapters. o Chapter 21 looks at different ways to read a fairly basic XML file and present it to the browser as an HTML table. It also looks into the PHP APIs SAX, DOM, and PRAX that allow interaction with an XML document, and the Sablotron XSL support for PHP. . Part 5 covers issues such as internationalizing, securing, and optimizing PHP applications. It also talks about the PHP extension libraries: o Chapter 22 is an exploratory dive into internationalizing scripts in PHP. It also traverses some more real world code challenges that demonstrate work arounds to the regular approach, and some architectural suggestions for effective use of non-linear language constructs. o Chapter 23 examines various aspects of security, from securing the server, securing the database and communications, and writing secure scripts, to choosing secure passwords. o Chapter 24 concerns itself with tips, tricks and techniques that can be used to optimize PHP code and relational databases. o Chapter 25 is all about the libraries that provide extensions to PHP’s core language. It talks about using PDFlib to generate PDF documents, Ming to generate dynamic Shockwave Flash files, HAWHAW to allow wireless users to view our sites, and uses the GD library to create dynamic images, thus catering to the needs of almost any Internet user. o Chapter 26 is a case study that demonstrates a general-purpose system for keeping track of user privileges. The four appendices are a complete reference for PHP taken from a CVS snapshot in between versions 4.0.5 and 4.0.6. This reference goes beyond the documentation written by the creators of the various APIs, filling in gaps where appropriate on CVS related material where possible, and adding text as necessary: . Appendix A is a list of all the extension functions . Appendix B lists all the basic and standard extension functions . Appendix C is a list of database functions . Appendix D lists the various configuration directives The appendices are available online at http://www.apress.com. We will keep this online resource updated to reflect subsequent version changes in PHP. Page 12
Note: If you are looking for cheap and reliable provider to host and run your servlet application check Vision servlet hosting services