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、一般页面通过GET接收的参数都是INT型(整型)居多,但是要防范一些不规范的输入,接收时用整型函数转换一下
$id=intval($_GET["id"]);
2、有上传功能时,一定要检查文件类型。不能任意由访客上载所有文件。(特别要注意一些HTML编辑器的漏洞)
3 ......
例子. return() 函数的用法
<?php
function square ($num)
{
return $num * $num;
}
echo square (4); // outputs '16'.
?>
函数不能返回多个值,但为了获得简单的结果,可以返回一个列表。
例子. 返回一个数组以得到多个返回值
<?php
function small_numbe ......
转自:http://www.w3school.com.cn/php/func_string_substr.asp
PHP substr() 函数
PHP String 函数
定义和用法
substr() 函数返回字符串的一部分。
语法
substr(string,start,length)
参数描述
string
必需。规定要返回其中一部分的字符串。
start
必需。规定在字符串的何处开始。
正数 - 在字符串的指定位置开 ......
首先我们要介绍一下我们在这篇文章中使用的PHP类Libchart,这是个外国人(非中国国籍的地球人,被称为外国人!)写的免费类!使用起来非
常简单。看出来了吧,我们是要用一个外国人写的PHP创建柱状图,饼状图,和线性图的类,来工作的。如果你要学习这个类的写法,你也可以把这个类下载下来看看外国人的思路!
我们开始吧 ......
1)发送路径中的参数有中文,在服务器端接收参数值是乱码
解决方法:
PHP:
服务器端:iconv("UTF-8","gb2312",$_POST[变量名]);
JSP:
客户端:
利用javascript的提供的escape()或encodeURI()方法, 例
var url="a.jsp?name=小李";
url=encodeURI(url);
url=encodeURI(url); //两次,很关键[具体为什么,我也不清楚 ......