<?php
function translate( $text, $destLang = 'zh-cn', $srcLang = 'en' ) {
$text = urlencode( $text );
$destLang = urlencode( $destLang );
$srcLang = urlencode( $srcLang );
$trans = @file_get_contents( "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q={$text}&langpair={$srcLang}|{$destLang}" );
$json = json_decode( $trans, true );
if( $json['responseStatus'] != '200' ) return false; else return $json['responseData']['translatedText'];
}
echo translate('me');
?>
- 3月 13 週日 201122:22
PHP - google tanslate api PHP source code
- 12月 10 週五 201000:35
javascript 防右鍵
<noscript><iframe src=*.html></iframe></noscript>
<script>
if(self != top) top.location.href = window.location.href;
</script>
</body>
- 11月 30 週二 201016:04
fixed location text with scroll bar of windows in CSS
CSS
<style type="text/css">
p.pos_fixed
{
position:fixed;
top:30px;
right:5px;
}
</style>
<style type="text/css">
p.pos_fixed
{
position:fixed;
top:30px;
right:5px;
}
</style>
- 11月 30 週二 201015:31
Create a new windows
html
<html>
<head>
<script type="text/javascript">
</script>
</head>
<body>
<input type="button" value="Open 'myWindow'" onclick="openWin()" />
<input type="button" value="Close 'myWindow'" onclick="closeWin()" />
</body>
</html>
<html>
<head>
<script type="text/javascript">
</script>
</head>
<body>
<input type="button" value="Open 'myWindow'" onclick="openWin()" />
<input type="button" value="Close 'myWindow'" onclick="closeWin()" />
</body>
</html>
- 11月 30 週二 201015:24
A clock created with a timing event
html
<html>
<head>
<script type="text/javascript">
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html>
<html>
<head>
<script type="text/javascript">
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html>
- 11月 30 週二 201015:15
Create a welcome cookie
<html>
<head>
<script>
//TODO something
</script>
</head>
<body onLoad="checkCookie()">
</body>
</html>
1