PHP+Ajax实现Tab效果
用Ajax实现Tab效果的
先创建
ajax.php,在其中输入如下代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample 2_1</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
<!--
//Create a boolean variable to check for a valid Internet Explorer instance.
var xmlhttp = false;
//Check if we are using IE.
function creatXMLHttp(){
try
{
//If the Javascript version is greater than 5.
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
//alert ("You are using Microsoft Internet Explorer.");
}
catch (e)
{
//If not, then use the older active x object.
try
{
//If we are using Internet Explorer.
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
//alert ("You are using Microsoft Internet Explorer");
}
catch (E)
{
//Else we must be using a non-IE browser.
xmlhttp = false;
}
}
//If we are using a non-IE browser, create a javascript instance of the object.
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
xmlhttp = new XMLHttpRequest();
//alert ("You are not using Microsoft Internet Explorer");
}
}
function makerequest(serverPage, objID)
{
creatXMLHttp();
var obj = document.getElementById(objID);
xmlhttp.open("GET", serverPage);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
obj.innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
相关文档:
1.如果一个方法可静态化,就对它做静态声明。速率可提升至4倍。
2.echo 比 print 快。
3.使用echo的多重参数(译注:指用逗号而不是句点)代替字符串连接。
4.在执行for循环之前确定最大循环数,不要每循环一次都计算最大值。
5.注销那些不用的变量尤其是大数组,以便释放内存。
6.尽量避免使用__get,__set,__a ......
1、一般页面通过GET接收的参数都是INT型(整型)居多,但是要防范一些不规范的输入,接收时用整型函数转换一下
$id=intval($_GET["id"]);
2、有上传功能时,一定要检查文件类型。不能任意由访客上载所有文件。(特别要注意一些HTML编辑器的漏洞)
3 ......
根据GyPSii API提供的操作类和方法,发现请求会失败,返回的是一个bed request。原因其实很简单,但一直没有找到,最终原因是对方提供的host是错误的,没天理。
对方提供的host和uri:
host:http://dev3.gypsii.com/gypsii
uri:http://dev3.gypsii.com/gypsii/xmlservice.cgi
这个host就是错的,应该是:dev3.gypsii.co ......
方法一:
<?php
function extend_1($file_name)
{
$retval="";
$pt=strrpos($file_name, ".");
if ($pt) $retval=substr($file_name, $pt+1, strlen($file_name) - $pt);
return ($retval);
}
?>
方法二:
function extend_2($file_name)
{
$extend = pathinfo($file_name);
$extend = strto ......
类文件wordsplit.class.php:
<?php
/********************************************************************
* DirCMS中文分词类 beta 1.0
* ---------------------------
* begin : 2010-5-11 beta 1.0
* update : 2 ......