Programming

PHP Function:  Built-in Functions part 10

PHP Function: Built-in Functions part 10

Fadıl

Regular Expression Functions

ereg_replace() and eregi_replace()
The ereg_replace() and eregi_replace() functions replace instances of a pattern within a string and return the new string. The ereg_replace() function performs a clase-sensitive match, and eregi_replace() performs a case-insensitive match. Here is the syntax for both functions:

ereg_replace(pattern, replacement, string);
eregi_replace(pattern, replacement, string);

For example, you would use the following code to replace “ASP” with “PHP” in the string “I really love programming in ASP”:

Using Program Parameters in Java Part-3

Fadıl

Databases

Why not store parameters in a database? If your application is already using a database, you might consider defining a special table for this purpose. To hold key-value pairs you need two columns of type char: “key” and “value”. If you want a really flexible solution you should consider making a small (Swing or web?) application that can be used to insert and update the data in this table.

PHP Function:  Built-in Functions part 9

PHP Function: Built-in Functions part 9

Fadıl

Program Execution Functions
You can use PHP’s built in program execution functions to use programs residing on your system, such as encryption programs, third-party image manipulation programs, and so forth. For all program execution functions, the PHP user much have permission to execute the given program.

exec()
The exec() function executes an external program. its syntax is

exec(command, [array], [return_var]);

If an array is specified, the output of the exec() function will append to the array. If return_var is specified, it will be assigned a value of the program’s return status.

Using Program Parameters in Java Part-2

Fadıl

Alternatives to the command line

Giving parameters on the command line is not always the best way to enter properties for your program. A typical situation where something else is needed is when your Java program isn’t invoked through a main method. An good example is when you have coded a servlet for a web server. In this situation you may use the web.xml file to specify the parameters you need.

Using Program Parameters in Java Part-1

Fadıl

Introduction

Every programmer will encounter a situation where a choice must be made between various alternative solutions. Should tabular data be sorted in one way or another? What exactly is the graphical layout of your HTML pages? How often should you poll a queue? Most often you’ll know the path to take based on the requirements specifications, a design manual or some other kind of documentation, but now and then you’ll have to choose without help. Instead of just selecting one solution and hoping the customer will like it when he or she starts using your code, you could make it a “program parameter” or “option”.