Category: PHP

  • Tips for a Speedy Zend Studio

    I found a good article on how to speed up your Zend Studio (eclipse based) on Zend’s website. Hopefully everyone else will find it as helpful as I found it to be: http://kb.zend.com/index.php?View=entry&EntryID=480

  • Zend Server and Zend Studio9

    If you have Zend Server installed and you have an instance of MySQL that didn’t come with Zend Server, then Zend Studio will try to connect to the one that came with Zend Server. I discovered this the hard way when my PHPUnit tests kept failing in Zend Studio but ran perfectly from the command…

  • Validating An Email Address in PHP 5

    In PHP 5.2 Zend has added a function called filter_var(). It validates a lot of things for you without having to write any regular expressions or anything else. You do it like this: if (filter_var($emailAddress, FILTER_VALIDATE_EMAIL) !== false) { print ‘valid email’; } else { print ‘Invalid email’; } filter_var()returns the value back if its…

  • PHP – Get a visitor’s IP address

    /** * This function tries to get the real IP of the visitor even if they * are behind a proxy */ function getClientIp() { if (!empty($_SERVER[‘HTTP_CLIENT_IP’])) { $ip = $_SERVER[‘HTTP_CLIENT_IP’]; } elseif (!empty($_SERVER[‘HTTP_X_FORWARDED_FOR’])) { $ip = $_SERVER[‘HTTP_X_FORWARDED_FOR’]; } else { $ip = $_SERVER[‘REMOTE_ADDR’]; } return $ip; }

  • PHP Inheritance – Calling parent’s functions in child object

    Before I begin, let me just say that I have tested this in PHP 5.2. I don’t know if this will work for PHP 5.3. If anyone can confirm that it does, it will be great. You can do it with parent::someFunctionName(). You can do this from within an overloaded function also. It was confusing…

  • PHP and Sabre

    What is Sabre? Sabre is a company that has data of all flight schedules, etc. And, using their system, you can book flights, hotels, rent cars, etc. Getting PHP to talk with Sabre I tried PHP Soap and nuSoap. They both didn’t work for me because of their limitations. So I ended up writing a…

  • Processing forms in PHP

    For this article, I will assume that you (the reader) know what a form is and have a general idea of what needs to be done on the HTML side to submit a form. I will cover a bit about what needs to be done but I will not go into details (it will be…

  • Design Patterns – Singletons in PHP 5.x

    Design Patterns (and anti-patterns) are techniques of programming. There are a lot of design patterns. It is upto the programmer to pick and choose which patterns to use based on their needs. Singleton is also a design pattern. A singleton is a type of class which can have only 1 object of its kind through…