Blogs

get_cfg_var vs ini_get

由 joelhy 于 周四, 04/10/2008 - 14:51 提交。
  1. get_cfg_var() shows php.ini setting
  2. ini_get() shows current setting

get_cfg_var() is an old PHP 3.0 era function, that returns the value for a directive in the php.ini file. This value may be valid or invalid, depending on whether it was overwritten by other configuration methods (e.g., httpd.conf or .htaccess). This function will always return the value that was typed in php.ini, if any.

Zend Framework components Used in Project Babel

由 joelhy 于 周三, 01/02/2008 - 11:17 提交。
Livid的Project Babel用到的Zend Framework组件有:
  1. Zend_Cache
  2. Zend_Feed
  3. Zend_Http_Client
  4. Zend_Json
  5. Zend_Search_Lucene

Difference between Print and Echo in PHP

由 joelhy 于 周三, 01/02/2008 - 10:41 提交。
google一番后,总结如下:
  1. echo 效率比 print高
  2. print始终返回1,而echo无返回值
  3. echo 可有多参数,例如:echo "Hello ", "World!"#输出 Hello World!。print只能有一个参数
有一点需要注意的是,它们都是 language construct,而不是函数。

Max-width in IE 6

由 joelhy 于 周五, 09/21/2007 - 08:31 提交。
In IE6, following code can be used to emulate the max-width css property:
  1. _width: expression(clientWidth < 180 ? "auto" : "180px");
In IE7 and firefox, that is simpler:
  1. max-width: 180px;

Scale Down Image Using JavaScript

由 joelhy 于 周五, 09/14/2007 - 17:54 提交。

/**
 * Scaling image down to maxWidth X maxHeight
 */
function scaleDownImage(image, maxWidth, maxHeight)
{
	if ((image.width/image.height) > (maxWidth/maxHeight)) {
		if (image.width > maxWidth) {
			image.resized = true;
			image.width  = maxWidth;
		}
	} else {
		if (image.height > maxHeight) {
			image.resized = true;
			image.height = maxHeight;
		}
	}
}

Native XMLHttpRequest Support in IE 7.0 is NOT Ready

由 joelhy 于 周五, 07/13/2007 - 11:05 提交。
From jQuery 1.1.3.1 code Line4427-4429:
  1. // Create the request object; Microsoft failed to properly
  2. // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
  3. var xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();

jQuery tells us "new XMLHttpRequest()" has some problems in IE7, so think ActiveXObject first, native XMLHttpRequest second.

A Clock in Canvas

由 joelhy 于 周一, 07/09/2007 - 21:35 提交。
// Wait for the browser to load window.onload = function() { // Draw the clock clock(); // and re-draw the clock every second thereafter setInterval(clock, 1000); }; function clock() { // Get the current date and time var now = new Date(); var sec = now.getSeconds(); var min = now.getMinutes(); var hr = now.getHours(); hr = hr >= 12 ? hr - 12 : hr; // Get the drawing context of the element var ctx = document.getElementById('canvas').getContext('2d'); ctx.save();

jQuery新版发布,性能提升重大

由 joelhy 于 周三, 07/04/2007 - 19:37 提交。

7月1日jQuery 1.1.3发布,据jQuery官方博客介绍,相比1.1.2版本有了很大的性能提升,主要的改进有: