Archive for the ‘PHP’ Category
Javascript – Void operator
Void Operator
blocks returned values
(void expression/function call)
When either an HTML A tag’s href attribute or onclick event handler contain a JavaScript expression or function call, the void operator is placed before them in order to neutralize a value they may return. The void operator assures that the value will not be assigned to the href attribute.
If this step is not taken, the page content is replaced with that value or sometimes with the client’s hard drive directory listing. The most common place this “gotcha” shows up is when the window.open() method is placed in an A tag as the href’s value:
Open Sub Window
Or Here…
do something when link is clicked
Void Operator fixes the above errors just by showing up:
Open Sub Window
do something when link is clicked
The “(0)” following the void operator is sometimes used as a place holder for the returned value, but doesn’t necessarily have to be used, but I’ve included it because you will probably see it used on occasion.
Manually set PHP Session Timeout
Sometimes it is necessary to set the default timeout period for PHP. To find out what the default (file-based-sessions) session timeout value on the server is you can view it through a ini_get command:
// Get the current Session Timeout Value
$currentTimeoutInSecs = ini_get(’session.gc_maxlifetime’);
Change the Session Timeout Value
// Change the session timeout value to 30 minutes
ini_set(’session.gc_maxlifetime’, 30*60);
If you have changed the sessions to be placed inside a Database occasionally implementations will specify the expiry manually. You may need to check through the session management class and see if it is getting the session timeout value from the ini configuration or through a method parameter (with default). It may require a little hunting about.
