Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Terry Chay's Blog:
How much does a date() cost?
May 07, 2009 @ 16:18:28

In a new post to his blog Terry Chay looks at the real cost of a (call to) date() - the PHP function that can parse either the current or an inputted timestamp out into the date format you specify.

One of the fringe benefits of open sources an existing code base is that you have an opportunity to setting error_reporting on E_ALL | E_STRICT or perhaps rather just to 2147483647. When you do that you find small problems with your code base you missed the first time you sloppily wrote it. In my case, I noticed that date() was throwing strict errors.

Due to his resulting request to test the error (after submitting a ticket to fix the server's php.ini settings), he went about trying to test and see what the real impact of working with the date function was by developing his own simple benchmarking script. It runs through five different tests some with a default timezone set and some not. His results found that doing it in the script versus on the server's config didn't make much of a difference so he corrected the issue with a quick ini_set (or a date_default_timezone_set).

tagged: date timezone default benchmark iniset datedefaulttimezoneset

Link:

Brian Moon's Blog:
PHP session cookie refresh
May 14, 2008 @ 17:51:02

Brian Moon has posted a tip (and a bit of code) he's worked up to help make a users cookies last a bit longer than they were originally designed to:

When you start a session, if the user had no cookie, they get a new session id and they get a cookie. You can configure that cookie to last for n seconds via php.ini or session_cookie_set_params(). But, and this is a HUGE but for me, that cookie will expire in n seconds no matter what.

His method provides a way to extend the life of the cookies currently set for the domain by changing the time to live through a series of ini_get calls wrapped in a setcookie() call.

tagged: cookie session refesh timetolive setcookie iniset

Link:

Jacob Santos' Blog:
Zend Framework: Hackish Include Path Solution
Oct 02, 2006 @ 18:18:50

Jacob Santos was having a problem with the Zend Framework. It couldn't find its own files. So, he's come up with a hack that helps mod_php users to avoid the problem.

I've had problem with Zend Framework not being able to find its files, which is usually not good. The "workaround" of adding the realpath works, but would be overwritten when updating. Besides, going through the files just to add realpath locations is a hassle.

The php_value only works with mod_php, so good luck if you are running PHP using CGI/FastCGI. Actually, you'll have no luck, because it won't work using CGI.

Essentially, it uses the ihi_set function to define the correct include path. Check out the comments of the post for some other suggestions.

tagged: zend framework path solution hack iniset includepath zend framework path solution hack iniset includepath

Link:

Jacob Santos' Blog:
Zend Framework: Hackish Include Path Solution
Oct 02, 2006 @ 18:18:50

Jacob Santos was having a problem with the Zend Framework. It couldn't find its own files. So, he's come up with a hack that helps mod_php users to avoid the problem.

I've had problem with Zend Framework not being able to find its files, which is usually not good. The "workaround" of adding the realpath works, but would be overwritten when updating. Besides, going through the files just to add realpath locations is a hassle.

The php_value only works with mod_php, so good luck if you are running PHP using CGI/FastCGI. Actually, you'll have no luck, because it won't work using CGI.

Essentially, it uses the ihi_set function to define the correct include path. Check out the comments of the post for some other suggestions.

tagged: zend framework path solution hack iniset includepath zend framework path solution hack iniset includepath

Link:


Trending Topics: