. Updated Daily. Editions SDA India   SDA Indonesia
BUSINESS ENTERPRISE SOLUTIONS ARCHITECTURE INFORMATION SECURITY WIRELESS & MOBILITY DATA & STORAGE DEVELOPMENT HARDWARE













News

Friday, 16 March 2007

Article: Command-line PHP to Debug PHP Code

 

 

Roger McCoy over the IBM web site provides an article on how to learn to debug PHP code from the command line and examine the strengths of PHP as a shell scripting language unto itself. He says you can use your PHP as your Swiss army knife for almost any given programming project.

He explains the tutorial under the following sections:

Installation

He says installation is straightforward and he instructs you to try a simple PHP script on the command line. He tells you to try an existing PHP script or the code that he gives in the tutorial.

PHP Debugging

He says that debugging of CLI programs can be nightmarish especially when dealing with HTML-embedded scripts, such as Microsoft Active Server Pages (ASP) or PHP. It can often be difficult to distinguish what precisely is meant by a specific error message, even the user input can be difficult to reproduce, he says. He shows how to apply CLI to solve the problems.

Locating and Fixing Errors using the CLI

He says running the script directly on the CLI can easily isolate the problem with the code. He shows how to do this with various examples.

PHP I/O Channels

He tells you to make the initial goal for your first PHP script a simple one. He instructs you to create a script that reads in a file and shuffles the lines in that file. This functionality can be handy if you're shuffling an m3u file or something similar, he says.

Your First PHP Shell Script

In this section he shows how to create a simple yet useful shell script. He gives a code to be typed in the Text Editor. With a few quick checks, he makes this script work.

Command-line Arguments

He initiates that real command-line programs use arguments. He says, just like C and other similar languages, you can use argv and argc for this purpose. He gives an example code, which spews a fully functioning CLI PHP program that accepts either user input or a list of files and randomizes the relative contents of each file.

 

Read the Article

 
 
print save email comment

print

save

email

comment

 
 

Search SDA Asia

Free eNewsletter

SDA Asia Magazine Free Download
 
 
 
Copyright @ 2009 SDA Asia Magazine - All Right Reserved Privacy Policy | Terms of Use