摘要:
function addEventHandler(elm,eventType,handler){ elm=typeof elm=="string"?document.getElementById(elm):elm; if(elm.attachEvent){ elm.attachEvent("on"+eventType,handler); }else if(elm.addEventListener){ elm.addEventListener(eventType,handler,false); }else return false;}//绑定事件 --解决 阅读全文
posted @ 2012-03-10 10:42
xngeer
阅读(712)
评论(0)
推荐(0)
摘要:
function stopPropagation(e){ e=window.event||e; if(document.all){ e.cancelBubble=true; }else{ e.stopPropagation(); }}用法:document.getElementsByTagName("li")[0].onclick=function(e){ alert("li"); stopPropagation(e);} 阅读全文
posted @ 2012-03-10 10:42
xngeer
阅读(502)
评论(0)
推荐(0)
摘要:
function isNumber(s){ return !isNaN(s);}function isString(s){ return "string"==typeof s;}function isBoolean(s){ return "boolean"==typeof s;}function isFunction(s){ return "function"==typeof s;}function isNull(s){ return s==null;}function isUndefined(s){ return "und 阅读全文
posted @ 2012-03-10 10:40
xngeer
阅读(883)
评论(0)
推荐(0)
摘要:
如:给ul下的li(或li下的XX)绑定事件<ul id="ul1"> <li><span>1</span></li> <li>2</li></ul><script type="text/javascript">function addEventHandler(elm,eventType,handler){ elm=typeof elm=="string"?document.getElementById(elm):elm; if 阅读全文
posted @ 2012-03-10 10:39
xngeer
阅读(1328)
评论(0)
推荐(0)
摘要:
用函数原型实现像java bean的效果function myApp(){ this.name="co2"; this.age=23;}myApp.prototype.getName=function(){ return this.name;}myApp.prototype.setName=function(name){ this.name=name;}var app=new myApp();alert("app.name:"+app.getName()); //co2app.setName("co22");alert("a 阅读全文
posted @ 2012-03-10 10:38
xngeer
阅读(1626)
评论(0)
推荐(0)
摘要:
PHP substr strpos$pos=strpos("12345", "3");$substring=substr("12345", 0,$pos);echo $substring;输出:12JAVA subString indexofString str="12345";int pos=str.indexOf("3");String substring=str.substring(0, pos);System.out.println(substring);输出:12PHP 从最末一个&q 阅读全文
posted @ 2012-03-10 10:37
xngeer
阅读(194)
评论(0)
推荐(0)
摘要:
大体上这篇贴很简洁实用(本人喜欢把条条理理写的很漂亮的人,谢谢永福)转:PHP执行系统命令(简介及方法)在PHP中调用外部命令,可以用如下三种方法来实现:方法一:用PHP提供的专门函数(四个):PHP提供4个专门的执行外部命令的函数:exec(), system(), passthru(), shell_exec()1)exec()原型: string exec ( string $command [, array &$output [, int &$return_var ]] ) 说明: exec执行系统外部命令时不会输出结果,而是返回结果的最后一行。如果想得到结果,可以使用 阅读全文
posted @ 2012-03-10 10:37
xngeer
阅读(1442)
评论(0)
推荐(0)
摘要:
想看到函数返回的bool结果,但bool结果不能在浏览器输出怎么办?<?phpvar_dump(is_file('a_file.txt')) . "\n";var_dump(is_file('/usr/bin/')) . "\n";?>输出:bool(true)bool(false) 阅读全文
posted @ 2012-03-10 10:36
xngeer
阅读(2289)
评论(0)
推荐(0)
摘要:
<?php $fileName=$_GET['file']; header('Content-type:application/force-download'); header('Content-Disposition:inline,filename='.$fileName); $fp=fopen("文件目录".$fileName, "r"); $content=fread($fp, filesize("文件目录".$fileName)); echo $content;?>/ 阅读全文
posted @ 2012-03-10 10:35
xngeer
阅读(237)
评论(0)
推荐(0)
摘要:
本函数可能理论上说有些不地道,把utf-8的中文字符和char一视同仁,都按长度为1计算function string_substring($string,$start,$length) { $countstart=0; $countlength=0; $printstring=""; for($i=0;$i<strlen($string);$i++) { while($countstart<$start) { $countstart++; if(ord(substr($string,$i,1))>128) { $i+=3; } else{ $i++; } 阅读全文
posted @ 2012-03-10 10:34
xngeer
阅读(482)
评论(0)
推荐(0)
摘要:
PHP session 变量用于存储有关用户会话的信息,或更改用户会话的设置。Session 变量保存的信息是单一用户的,并且可供应用程序中的所有页面使用。理解:session用于单一用户与服务器的交互,每个用户的session都是不一样的。session作为全局变量,在浏览器开户期间所有页面内有效。Session 的工作机制是:为每个访问者创建一个唯一的 id (UID),并基于这个 UID 来存储变量。UID 存储在 cookie 中,亦或通过 URL 进行传导。在把用户信息存储到 PHP session 中之前,首先必须启动会话。注释:session_start() 函数必须位于 < 阅读全文
posted @ 2012-03-10 10:34
xngeer
阅读(194)
评论(0)
推荐(0)
摘要:
php textarea中的换行符为"\r\n"不是'\n'不是"<br />"不是'\r\n'不是'\r'+'\n' 阅读全文
posted @ 2012-03-10 10:33
xngeer
阅读(693)
评论(0)
推荐(0)
摘要:
function getConnection(){ @mysql_connect("localhost","username","password") or die("无法连接数据库"); @mysql_select_db("databasename") or die("未找到数据库"); }getConnection(); $query="select definition,accession,gi from birds_nucleotide order by d 阅读全文
posted @ 2012-03-10 10:32
xngeer
阅读(179)
评论(0)
推荐(0)
摘要:
文件目录:--index.php--php--data_info.phpindex.php这里要require_once类所在的php文件<?phprequire_once('./php/data_info.php'); $oneData=new user; $oneData->setName("username"); $oneData->setPassword("password"); echo $oneData->getName(); echo $oneData->getPassword();?>d 阅读全文
posted @ 2012-03-10 10:32
xngeer
阅读(266)
评论(0)
推荐(0)
摘要:
阅读全文
posted @ 2012-03-10 10:31
xngeer
阅读(359)
评论(0)
推荐(0)
浙公网安备 33010602011771号