Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 WEB


  Set PHP session timeout

There are many different discussions about PHP sessions. We may often face some weird issues while handling PHP sessions. Sometimes session is expired earlier than expected. Or sometimes the session is not expired. This introduces many confusions.Today we discuss how to set PHP session timeout correctly today. In php.ini, there are three key parameters which will affect the session timeout. session.gc_maxlifetime, session.gc_probability and session.gc_divisor. session.gc_maxlifetime defined the lifetime of a session in seconds which indicates when the session will be garbage collected. Then se...

21,301 3       PHP SESSION TIMEOUT


  HTML Email Guide

Many of us may subscribe to some newsletters to get update about their site or information about a topic such as JavaScript Weekly, we may receive an email every week or every month to know what's happening there.The email we receive is just a simple HTML page but with an Email format called HTML Email. It seems it's simple to write this kind of HTML Email. But the thing is it's not so easy. It takes much effort by just designing an Email template.Whether the HTML Email can be displayed normally depends completely on the mail client. Most mail clients such as Outlook and Gmail will filter the ...

21,209 0       HTML EMAIL GUIDE


  Can a == true && a == false be true in JavaScript?

JavaScript is a weak typed language and it has a loose comparison feature where two objects/values of different type can be compared using == operator. This provides developers great flexibility and confusion at the same time. Before understanding how == works in JavaScript, can you first answer the question in the post title? Can a == true && a == false be true in JavaScript? Normally, we would think that this expression will always return false since a can be either true or false but cannot be both. However, in JavaScript, the above expression can return true indeed.If we h...

19,405 2       == JAVASCRIPT INTERVIEW QUESTION COMPARISON


  PHP Sucks! But I Like It!

I read a rather interesting post yesterday called PHP: a fractal of bad design. It's been getting a lot of traffic among the PHP community lately because it's rather inflammatory. But to be honest, it does make a lot of really good points. It also makes a lot of mistakes and misses a bigger picture.A Few MistakesThe post makes quite a few mistakes and odd apples to oranges comparisons. Let me point out the major ones that I saw.No Debugger - PHP has xdebug which works quite well as an interactive debugger.Lack Of Threading - This is true, but he lists it as a difficulty, and I list it as ...

19,172 0       PHP LIKE BAD DESIGN


  PHP: a fractal of bad design

PrefaceI’m cranky. I complain about a lot of things. There’s a lot in the world of technology I don’t like, and that’s really to be expected—programming is a hilariously young discipline, and none of us have the slightest clue what we’re doing. Combine with Sturgeon’s Law, and I have a lifetime’s worth of stuff to gripe about.This is not the same. PHP is not merely awkward to use, or ill-suited for what I want, or suboptimal, or against my religion. I can tell you all manner of good things about languages I avoid, and all manner of b...

18,851 3       PHP DESIGN ANALYSIS


  PHP buffer: output_buffering and ob_start

buffer is one piece of memory section, it is usually 4Kb in Linux. It is mainly used between different devices with different speed or different priorities. With buffer, the waiting time between different processes will be reduced. Here is one simple example, when you type something in a text editor, every time when you type a character, the operating system will not write it to the disk directly, instead it will write it to buffer first When the buffer is full, the data in the buffer will be written to disk. But when you call flush(), the data in the buffer will be written to the disk immedia...

18,817 1       PHP BUFFER OUTPUT_BUFFERING OB_START


  Get hostname from a URL using JavaScript

Sometimes we may have strings which contain some UR;s and we may want to retrieve the hostname from the URLs for some statistic use. For example, we may have a URL : http://www.example.com/aboutus.html. We may want to retrieve the www.example.com from the URL. How? Use regular expression. Here I give an example using JavaScript. If you want to check whether a string is a URL or not. Refer to Detect URLs in a Block of Text. In JavaScript, we can have a regular expression like var pattern=/(.+:\/\/)?([^\/]+)(\/.*)*/i;the regular expression pattern can be used to get the hostname. There are three...

18,579 0       JAVASCRIPT REGULAR EXPRESSION URL HOSTNAME


  PHP to get access token for Sina Weibo app

Previously I wrote two articles about getting access token for Facebook and Twitter apps using PHP. Today I will write one more article about getting access token for Sina Weibo app using PHP.OAuth 2.0 is now the authorization mechanism of Sina Weibo API. The API authorization process is similar to the process of Twitter. It has basically two steps: 1. Authorization; 2. Get access token.1. Create an app.I hope you know how to create an app in Sina Weibo now. If not. You can access this page and it will guide you on how to create the app. After you creating the app. You should write down the Ap...

18,527 2       PHP ACCESS TOKEN SINA WEIBO