function charTranslate($str){
$str = strtr($str, array('€'=>"EUR",
"\\"=>"",
"/"=>"",
"š"=>"¨",
"Ž"=>"´",
"ž"=>"¸",
"Œ"=>"¼",
"œ"=>"½",
"Ÿ"=>"¾",
"ä"=>"ae",
"Ä"=>"AE",
"ö"=>"oe",
"Ö"=>"OE",
"ü"=>"ue",
"Ü"=>"UE",
"ß"=>"ss")
);
return $str;
}
2009年1月10日星期六
2008年12月16日星期二
mysql 数据库备份
mysqldump -h db481.1und1.de -P 3306 -udbo263011116 -pxy.cTPv8 db263011116 --compact --tables sms_history -w"f_clientid = '1' AND DATE_FORMAT(senddate,'%m') = DATE_FORMAT(CURRENT_TIMESTAMP() - INTERVAL 1 MONTH ,'%m')" | gzip > _DB/Backup/TESTSEITE_12-2008.gz
"--compact" :Produce less verbose output. This option enables the --skip-add-drop-table, --skip-add-locks, --skip-comments, --skip-disable-keys, and --skip-set-charset options.
2008年12月5日星期五
PHP:取得变量名
源程序:
改进后:
/* 取得变量的名字 */
function getVarName(&$src)
{
//存储当前变量值
$save = $src;
//存储所有变量值
$allvar = $GLOBALS;
//在函数中不要直拉遍历$GLOBALS,会出现堆栈问题
foreach($allvar as $k=>$v)
{
//变量值相同,可能不是相同变量,因多个变量的值可能相同
if ($src == $v)
{
//改变当前变量$src的值
$src = 'change';
//如果$GLOBALS[$k]也跟着改变,那就是同一个变量。
if ($src == $GLOBALS[$k])
{
echo "\$$k name is $k
";
}
}
}
//还原变量值
$src = $save;
}
$test = "helo";
$test2 = "helo";
getVarName($test);
?>
改进后:
function getVarName(&$src)
{
$save = $src;
$allvar = $GLOBALS;
foreach($allvar as $k=>$v)
{
if ($src == $v)
{
$src = 'change';
if ($src == $GLOBALS[$k] && $k != 'argc')
{
//echo "\$$k name is $k
";
$src = $save;
return $k;
}
}
}
$src = $save;
}
2008年11月4日星期二
javascript 打印print 窗口
var invoiceWindow=window.open('','','width=1,height=1,location=NO,locationbar=NO,menubar=YES,screenX=100,screenY=100');
invoiceWindow.document.write("hallo, this is new window");
invoiceWindow.document.close(); // --> Sehr wichtig
invoiceWindow.print();
invoiceWindow.close();
2008年9月23日星期二
Prototype JS Event.observe
Event.observe(window, 'load', function()
{
Event.observe( 'searchBt', 'click', function(e)
{
ajaxListReceiver('{$clientId}');
getWinnerCount(0);
Event.stop(e);
});
});
var phrase = "This is SPAARRTTAAAA!";
$('somelink').observe('click', sayIt.bindAsEventListener(this, phrase));
function sayIt(event, phrase) {
console.log(phrase);
}
phrase = "Red sauce on PAASTAAAA!";
var obj = { name: 'A nice demo' };
function handler(e) {
var tag = Event.element(e).tagName.toLowerCase();
var data = $A(arguments);
data.shift();
alert(this.name + '\nClick on a ' + tag + '\nOther args: ' + data.join(', '));
}
Event.observe(document.body, 'click', handler.bindAsEventListener(obj, 1, 2, 3));
// Now any click on the page displays obj.name, the lower-cased tag name
// of the clicked element, and "1, 2, 3".
/*
* add click event
*
*/
// Attaching events
for (var i = items.length; i--; ) {
Event.observe(items[i], 'click', e_onclick, false);
}
// Detaching events
for (var i = items.length; i--; ) {
Event.stopObserving(items[i], 'click', e_onclick, false);
}
/*
* add click event with "return false"
*
*/
in html file:
Event.observe(window, 'load', function() {
Event.observe('button2', 'click', onchecktime);
});
if js file:
var onchecktime = function(event){
var element = Event.element(event);
alert(Event.pointerX(event));
Event.stop(event); // avoid page reloading
};
2008年9月22日星期一
Prototype JS Event.observe
CODE:
/*
*you'd want this line of code to run once the form exists in the DOM; but putting *inline scripts in the document is pretty obtrusive, so instead we'll go for a simple *approach that waits till the page is fully loaded:
*/
Event.observe(window, 'load', function() {
Event.observe('percent', 'change', selectProPercent);
}
in main.js:
var selectProPercent = function()
{
......
}
/*
*you'd want this line of code to run once the form exists in the DOM; but putting *inline scripts in the document is pretty obtrusive, so instead we'll go for a simple *approach that waits till the page is fully loaded:
*/
Event.observe(window, 'load', function() {
Event.observe('percent', 'change', selectProPercent);
}
in main.js:
var selectProPercent = function()
{
......
}
订阅:
博文 (Atom)