PHP headers to serve JSON
1 2 header('Cache-Control: no-cache, must-revalidate'); 3 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 4 header('Content-type: application/json');
13501 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Jeffrey Barke http://jeffreybarke.net/
1 2 header('Cache-Control: no-cache, must-revalidate'); 3 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 4 header('Content-type: application/json');
1 mysql_insert_id()while using SQL Server. From PHP manual.
1 2 function mssql_insert_id() { 3 $id = false; 4 $res = mssql_query('SELECT @@identity AS id'); 5 if ($row = mssql_fetch_row($res)) { 6 $id = trim($row[0]); 7 } 8 mssql_free_result($res); 9 return $id; 10 }
1 2 sqlite3 ~/Library/Mail/Envelope\ Index vacuum;
1 2 //this is safe only if you can assure object has not been extended. 3 var array = new Object(); 4 //use the below if Object has been extended 5 var array; 6 //everything below here works fine regardless of the two above cases 7 array['something'] = 'foo'; 8 array['somethingelse'] = 'bar'; 9 for (keyVar in array) { 10 alert(keyVar + '--' + array[keyVar]); 11 }
1 2 header('HTTP/1.0 301 Moved Permanently'); 3 header('Location: http://new-page.com/'); 4 header('Connection: close'); 5 exit();
1 2 Options +FollowSymLinks 3 RewriteEngine on 4 5 RewriteCond %{HTTP_HOST} ^www.old-domain.com$ [NC] 6 RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L]
1 2 Function stripTags(HTMLstring) 3 Set RegularExpressionObject = New RegExp 4 With RegularExpressionObject 5 .Pattern = "<[^>]+>" 6 .IgnoreCase = True 7 .Global = True 8 End With 9 stripTags = RegularExpressionObject.Replace(HTMLstring, "") 10 Set RegularExpressionObject = nothing 11 End Function
1 2 function uniqueFilename($strExt = '.tmp') { 3 // explode the IP of the remote client into four parts 4 $arrIp = explode('.', $_SERVER['REMOTE_ADDR']); 5 // get both seconds and microseconds parts of the time 6 list($usec, $sec) = explode(' ', microtime()); 7 // fudge the time we just got to create two 16 bit words 8 $usec = (integer) ($usec * 65536); 9 $sec = ((integer) $sec) & 0xFFFF; 10 // fun bit--convert the remote client's IP into a 32 bit 11 // hex number then tag on the time. 12 // Result of this operation looks like this xxxxxxxx-xxxx-xxxx 13 $strUid = sprintf("%08x-%04x-%04x", ($arrIp[0] << 24) | ($arrIp[1] << 16) | ($arrIp[2] << 8) | $arrIp[3], $sec, $usec); 14 // tack on the extension and return the filename 15 return $strUid . $strExt; 16 }