PHP 5.x Archives

Bendable runtime methods and member variables in PHP5

IBM:
The introduction of new object-oriented programming (OOP) features in PHP V5 has significantly raised the level of functionality in this programming language. Not only can you have private, protected, and public member variables and functions — just as you would in the Java™, C++, or C# programming languages — but you can also create objects […]

AJAX MyTop

Man, how many clicks does it take to get the download these days at Sourceforge? Seems like it took me a half dozen to get to the AjaxMyTop project download.

MyTop creator Jeremy Zawodny writes:
Someone has built and AJAX powered version of mytop, the little console based MySQL monitoring tool I wrote years ago. I guess […]

PHP 5.1.0 now available

PHP 5.1.0 has been released on Thanksgiving. Changelog

symfony open source php5 framework

Based on the concept of Rails / Django like framework only for PHP, here comes the MIT licensed symfony

Parsing names and numbers out of text

At one of our sites we needed to parse out some names and numbers from a log file. The strings also contained comment text and the order would be mixed format. These types of regular expression parsing can be tricky.
Let’s take a look at the two possible formats of the strings:
FORMAT #1:
[00:02:18][jvastine]7.52..I agree with […]

Using header to redirect the browser

The PHP header function allows redirection of the browser, among other cool things.
Example redirecting the browser to php-scripts.com homepage:

<?php
header(”Location: http://www.php-scripts.com/”);
?>

Using floor and time to calculate number of days elapsed from UNIX timestamp

Finding out the number of days elapsed from a UNIX timestamp is actually pretty straightforward. If you only know two dates then first you’ll need to convert the date to a UNIX timestamps and then subtract the most recent timestamp from the older timestamp like this:

<?php
$old_timestamp = 1102971600;
$elapsed_seconds = time() - $old_timestamp;
print ‘Seconds elapsed since […]

How to use preg_replace to replace phrase between question marks

<?php
$string = “?This is a test that should be in single quotes quotes?”;
$text = preg_replace(”/(\?([^\?]+)\?)/”,”‘\\2′”,$string);
?>

regular expression produces:
This is a test that should be in single quotes’

How to make an anniversary counter announcement script using ordinal numbers

Today being it is our 16th wedding anniversary I decided it would be appropriate to build a small script to keep track and post a message automatically on our special day together. I wanted this program to remember what year of our anniversary it was without me having to remind it: a great use for […]

How to PHP scripting course begins Friday 9/23/2005

For those who would like to learn how to write PHP code, starting next Friday at Webmaster Cookbook, our family friendly webmaster how-to site/blog, we’ll be going through a 32 week course on PHP programming. Details will be announced during the radio show and podcast next Friday September 23, 2005 at 3:30pm PST. For those […]