IT DRILLDOWN
 
NEWSLETTERS
 

CIO.com updates, insights and advice on technology, management and your career.

 
 
 
LEADERSHIP
 
CIO Executive Programs
The Leader in Face-to-Face Education for Senior Executives

Offering regional and national programs, CIO (and CSO) events bring together some of the most respected names and thought leaders in information technology and security. Presented by CIOs and other senior level executives, these invitation-only programs offer timely topics and strong networking. Learn More »

 
CIO Executive Council
A Peer-Advisory Service and Professional Association for CIOs

Public Teleconferences
Join CIO Executive Council members and participate in the following live teleconferences:

* Planning for Succession:
Models for IT Leadership Development, June 23
* Change Leadership at General Growth Properties: A
Pathways Leadership Development Seminar, June 25
* Managing Change: Centralizing Your IT Organization
July 29

More / Register »

Learn more about the CIO Executive Council »



 
 
RESOURCE CENTER
 
 
 
SUBSCRIBE TO CIO
 
Are you involved in setting the direction for your company's IT budget or strategy?

Apply today for a FREE subscription to CIO Magazine!

 
 

Feature

 

You Used PHP to Write WHAT?!

PHP may be the most popular Web scripting language in the world. But despite a large collection of nails, not every tool is a hammer. So when should it be used, and when would another dynamic programming language be a better choice? We identify its strengths and weaknesses.
 

January 25, 2008CIO — There is no single right answer to every problem and PHP is no exception. The dynamic programming language has its strengths and its weaknesses like any other language. PHP integrates very well with HTML and has hundreds of functions that make it a very capable programming language for a variety of tasks. It also has the ability to interact with the operating system like a scripting language. PHP is also widely held as the way to interact with databases of almost every type.

PHP is the go to guy for Web programming languages but are there things better left to Perl, Ruby, Java, JavaScript or Python? You bet there are. In particular, PHP is not thread safe—which means that multiple instances of the same routine may interact with each other, resulting in a crash on the Web server. PHP has suffered its share of security problems, and it isn't particularly well-suited to large or extremely complex site implementations.

Despite some of its significant shortcomings, PHP is perhaps the most popular Web scripting language currently used in the world. Why is that? Some of the reasons may surprise you.

Editor's Note: As the number of comments on this article demonstrate, several readers disagreed with our author's opinions. Those readers may wish to also read our followup article: PHP's Enterprise Strengths and Weaknesses, Take 2, in which Zend's John Coggeshall responds with his own list of the Good, the Bad and the Ugly of PHP application development.

PHP's Shining Beacon

Several dynamic or "scripting" languages, including PHP, Perl, Java and others, have their roots in the C language, which makes them a natural fit for developers making the transition from traditional application programming to Web programming. This makes the learning curve far less steep for those used to standard procedural languages. PHP has the advantage since it also integrates very well with HTML.

In fact, its full name is PHP: Hypertext Preprocessor (one of those famous Unix recursive acronyms), which means that it understands hypertext (HTML) without any special API or modifications. An API, application programming interface, is a set of libraries that allow programmers to interact with operating systems, databases or other applications by referencing those libraries inside an application. PHP has a long list of APIs and functions that expand its capability beyond that of any other contemporary Web scripting language.

PHP has enjoyed a long-lived association with databases, especially MySQL. However, PHP plays equally well with Oracle, DB2, SQLite, PostgreSQL, Sybase and Microsoft's SQL Server. Migrating from one database server to another is usually quite simple since most of PHP's functions have a common naming convention. A programmer can do simple global pattern replacements to change from one database brand to another. The following is an example of some often used MySQL functions and their Microsoft SQL Server equivalents.

MySQL MS SQL
mysql_connectmssql_connect
mysql_querymssql_query
mysql_fetch_array mssql_fetch_array

As you can see in the table, an application that accesses a MySQL database can be redesigned as a Microsoft SQL Server application with minimal effort.

PHP is available for almost every current operating system. This makes the code portable to other platforms with few, if any, changes. If you run a PHP website on Windows with IIS and it crashes, you can use the PHP scripts and pages on a PHP-enabled Linux server with minor modifications. You have to change any absolute paths and some parameters only in the PHP configuration file. For similar systems (Unix to Linux), you may only have to copy the files to the new server and restart your Web server.

PHP enjoys such widespread popularity because:

  • It is easy to learn: Its C-like syntax makes it an easy language to learn for programmers and nonprogrammers alike.
  • It blends well with HTML: You can mix PHP scripts right inside your HTML or place HTML tags and code inside PHP files.
  • PHP has a vast library of functions and APIs: PHP's ability to interact with LDAP, databases and the file system makes it a great "one stop shop" for developers.
  • You can rapidly create Web applications and database-backed applications: PHP is so often used with databases, especially open-source databases, that several books are available on the shared topic of PHP and MySQL.
  • It is cross-platform capable: PHP is used on Windows, Linux, commercial flavors of Unix and MacOS X.

When should you use PHP?

  • Creating an intranet site.
  • Prototyping an application that will be converted to Java or some other language.
  • Creating a Web database application.
  • Deploying an inexpensive or quick solution.
  • Using ready-made apps from Sourceforge.net or other sites.

 
 
 
 
 
 
Loading...
 
 
ABCs
 

How To Do Nearly Anything

Just the basics, please. Sometimes we all need a refresher or we need to make sure our team and our colleagues are all on the same page.

Over 25 tutorials on everything from business intelligence to virtualization.

 
 
FEATURED SPONSORS
 
 
 
SPONSORED LINKS
 

Efficient by design: Watch this flash demo of the Quad-Core AMD Opteron Processor

Renowned Engineering Institution Chooses AMD Processor-Based Servers

Establishing a Strategy for Global Distributed Development

Cost-Effective Data Center 1U Server Solutions

Automate Business Processes - Try a Free Mashup Composer

Read Forrester's advice for deploying an enterprise mobile solution

Do the math-calculate the impact of mobile device deployment on your bottom line

Easily manage the Mac in your Enterprise

GET YOUR VoIP ONTM! Win 2 Years of Hosted VoIP from Cypress. $100,000 retail value. Enter today!

Build up or Tear down? See how UC makes sense with Nortel. Calculate your UC ROI

Speed, agility, flexibility - The HP BladeSystem c-Class

See why 93 of the Fortune Global 100 depend on Blue Coat.

Strategies to Run a Lean Supply Chain

Evolving to a Business Process Platform with SAP Solutions

Webcast: Achieving business alignment and agility with the right capabilities framework

The Advantages of Identity Based Encryption

Regulations Shift Focus on Outbound Email Security

White Paper: How Visualization Can Fix Business Software Problems

Oxford International Modernizes Vehicle Order Management System

Learn about the Three Pillars of Data Protection

Putting Open source to the test

Juniper Networks is changing the economics of networking with a no-compromise, highperformance and service-oriented approach

Research about the efficiencies created by different operating systems.

IT Outsourcing: To Rebid or Renegotiate Webcast

Create and Run Any Application On-Demand

HP and Oracle deploy unbreakable computing infrastructure at Replacements, Ltd.

White Paper: Assess Your SOA

Extending the Enterprise Network Through Mobility

Microsoft System Center - Designed For Big

Choose a mobile device platform with familiar programs and simplified management

Improve device management - Microsoft® System Center Mobile Device Manager

Explore the interactive whitepaper: Rightsizing Blades for the mid-market

Easily integrate the Mac in your Enterprise

Reducing Data Center Costs with Data Deduplication: A TCO Analysis

Telwares helps firms validate, manage and optimize their telecom spend

TDWI Research report clears confusion about automating data governance

Taking Document Automation to the Next Level

How To Achieve Optimized Business Outcomes

Business Intelligence for Decision Makers

The Great Email Security Debate: Appliances, SaaS, or Virtual?

Messaging Security Goes Virtual

Outbound Email and Data Loss Prevention in Today's Enterprise

Webcast: Transformation of Application Development

Webcast: Building an Optimized Infrastructure

How to Avoid the Worst Practices in Business Intelligence

White Paper: Juniper Networks Ethernet Switching Solutions Reduce Operational IT Expenses

Webcast: Learn why companies must invest in an agile network infrastructure

White Paper: Businesses Thrive by Unifying Business Communications

Run Desktop and CRM Applications Side by Side with Salesforce & Google

User Interface as a Service - Visual Force