Posted by Jacob Wright in General, Object Oriented Programming, PHPSep 19th, 2005 | 20 Comments
In PHP 5 and greater there is a magic function called __autoload (note: two underscores). __autoload allows us to load a class on the fly so to speak. It only gets called when a class can not be found, then it has a chance to load the class. If the class still can not be found, you get your regular error stating so. __autoload can be really useful if all of your classes happen to be in one directory, but what happens if you are managing a large project with many packages of classes? We will look at some different options.
Single Directory of Classes
This is the simplest solution, and the best...
Posted by Jacob Wright in Applications, General, Javascript, PHPSep 14th, 2005 | 1 Comment
Mint is a new product recently released to track the statistics on your website. It has gotten much attention from several areas, and I thought it would be worth it to check it out.
I am currently using StatCounter.com to track the traffic to my site. It is really useful when you use their paid service which keeps track of more than the last 100 visits to your site (the free version cap). It lets you view all the regular stats as well as "drill down" to see the actual path a single visitor took through your site. But, it is a monthly subscription service, which means potenially hundreds of...
Posted by Jacob Wright in General, PHPSep 9th, 2005 | 5 Comments
This is a little trick to create a logout from your site if you are using HTTP Authentication. I am using it for a current project I'm working on where cookie based sessions won't reliably work. We (Derek Andriesian and I) are using HTTP Authenticaton to log into an account which is only accessed through javascript and image urls from other sites. Some browsers disallow cookies being set by sites other than the current one, so keepig the user logged in is not always possible using cookie-base session management.
To use HTTP Authentication you just do this in your PHP:
// retrieve the vars...
Posted by Jacob Wright in Flash, General, PHPAug 12th, 2005 | No Comments
AMFPHP (Flash Remoting written in PHP) has hit a stable version 1.0 release! I've been looking forward to this for a long time.
Flash Remoting is a method of transfering data to a Macromedia Flash Movie. It sends it in binary format and is much easier to use as it arrives in an object form, meaning, you don't have to sort through the child nodes of an XML object. I have been using AMFPHP for over a year on several projects (being one of the main backend developers in my company, mediaRAIN) to send stuff. I created the logo storage of LogoMaker/InstaLogo using AMFPHP which handles, and I quote,...
Posted by Jacob Wright in General, Object Oriented Programming, PHPAug 5th, 2005 | No Comments
One of the simple and very useful pieces of code in Pherret (a PHP 5 framework) is the setProperties() function in the base Object class. The name originally came from Java Beans and works in a similar manner. I'm sharing it because it could be used in any code with PHP 5 or PHP 4.
First, here is the problem being solved. Do you ever find yourself setting and object (or array, or variables) from a HTTP post in the following manner?
$user = new User();
$user->firstName = $_POST['firstName'];
$user->lastName = $_POST['lastName'];
$user->address = $_POST['address'];
$user->city...