|
Saturday, 28 October 2006
Most websites have “contact forms”, which allow customers to get in touch with the website owners, without the owners necessarily having to reveal their contact email address. The customer typically fills in their name, email address and some message text. When the customer submits the contact form for processing, the server software then constructs an email message and sends it to the website administrator or owner.
Read more >>
Saturday, 14 October 2006
It’s only recently that I discovered the PHP function fgetcsv(), which offers a quick and powerful way of handling CSV data, such as that exported by Excel and other spreadsheets.
Using fgetcsv(), the process of reading in a CSV file and printing the results in a HTML table is as simple as this:
$fp = fopen('test.csv', 'r') or die('cannot open file');
echo "<table>\n";
while ($line = fgetcsv($fp, 4096)) {
$max = count($line);
echo "<tr>\n";
for ($i = 0; $i < $max; $i++) {
echo "<td>{$line[$i]}</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
fclose($fp) or die('cannot close file');
The real power of fgetcsv() is that it automatically handles the double quotes and any embedded commas which may be present in the source data.
Wednesday, 20 September 2006
Here’s a simple way to strip all whitespace from a string in PHP, which is useful for properly trimming any user input:
function realtrim($mixed) {
if (is_array($mixed)) {
return array_map('realtrim', $mixed);
}
if (strlen($mixed) > 0) {
$mixed = trim(preg_replace('/[\s]+/', ' ', $mixed));
}
return $mixed;
}
The above function will strip all multiple spaces, tabs, line feeds and carriage returns. It also has the capability to accept an array as input, making it particularly suitable for web forms.
Friday, 4 August 2006
I stumbled across this one while doing some research on a totally unrelated topic. Having been sufficiently impressed with it’s simultaneous simplicity and affability, I thought I might share my findings.
Schedule Organizer is a PHP/MySQL online scheduling system which offers a flexible, easy to use and powerful web-based interface for your clients to request and manage appointments with your business or organisation.
Read more >>
Tuesday, 25 July 2006
PHPXref is a handy developer tool, written by Gareth Watts, which cross-references the source code in PHP projects and creates readable HTML documentation which can be viewed with any web browser. The main features of PHPXref are:
- No web server required to view output.
- Cross-references PHP classes, functions, variables, constants and require/include usage.
- Javascript search and instant lookup of classes, functions, constants and tables.
- Pretty output of PHP source files.
PHPXref requires Perl V5.6 or later to run and is available in Linux and Windows flavours. The Windows edition even includes the required Perl libraries, so installation is a cinch.
|