您的位置:首页 > 编程语言 > PHP开发

PHP常用知识点学习

2012-08-20 11:09 260 查看
一.开发环境搭建 eclipse+appserver_win32 :

首先安装好 eclipse,必须先安装jdk,然后安装phpeclipse 插件。



然后安装完appserver,启动apache服务器,



检查appserver是否安装成功:在浏览器中输入:127.0.0.1看不能看到该页面



二创建一个php工程步骤:



三.常用知识点学习:



常用函数:








test.php

<?php

// echo phpinfo();//显示php和apache配置信息

$result = "Test transfer reslt";

//unset 销毁指定变量

//1.销毁单个变量

//unset($result);echo $result;

//2.删除数组或者数组元素,取消一个数组的键名,数组不会重建索引

/*$a=array(1=>'one',2=>'two',3=>'three');

unset($a[2]);

$b= array_values($a);*/

/*if(empty($result)){//判断是否为空函数

echo "is null";

}else if(!isset($result)){//结果

echo "not null";

}*/



//var_dump 打印变量的相关信息

/*

$a=array(1,2,array("a","b","c"));*/

/*$var=array('a'=>'apple','b'=>'banana',array('x','y','x'));*/

//var_dump($a);



//$b=3.1;

//$c=TRUE;

//var_dump($b,$c);

// print_r($var);// 打印变量信息



/*$test=1;

if(gettype($test)=="string"){

echo "result right,is what type--->"+is_string($test);

}else if (gettype($test)=="integer"){

echo "result is int,and is:"+$test;



}else{

echo "type errors";

}*/

/*$hostname=gethostbyaddr($_SERVER['REMOTE_ADDR']);

echo "主机名是:".$hostname;

//根据主机名得到ip

$ip=gethostbyname('www.baidu.com');

echo "<br>";

echo "百度的ip是:".$ip;*/

/*

$a=array("foo"=>"bar",12=>true);

// unset($a);//删除数组

echo "统计数组中元素个数:".count($a)."<br>";

echo $a["foo"];

unset($a[12]);//根据键删除数组元素

echo $a[12];*/



$info=array('张三','男','23岁');

//取出数组所有元素赋值给这个3个变量

list($name,$Ssex,$age)=$info;

print("name$name,age:$age,sex:$sex");

//取出其中一个元素



list(,,$age)=$info;

print("<br>$age");



//将数组元素连接成字符串 implode



$array=array('lastname','eamil','phone');

$comm=implode("+",$array);

echo $comm;

echo date("Y-m-d");



Header("Location:http://www.baidu.com");





?>

<form action="result.php" method="get">



<input type="hidden" name="a" value="<?echo $result;?>" />



<input type="submit" value="提交"/>

<input type="reset" value="重置"/>

</form>



result.php

<?php

//echo $_POST['a'];//访问客户端变量 通过$_POST或者$_GET

echo $_GET['a'];



?>



x.php



<?php

session_start();//初始化session 在此之前不能像浏览及输出东西

session_register("s_name");//注册新的session变量

$s_name="孙守龙";//给s_name赋值

Header("Location:y.php");//跳转到y.php

?>



y.php



<?php

session_start();//初始化sessoin

echo "当前的用户是:".$s_name;

unset($s_name);//从内存删除该元素

/*session_destroy();//删除session文件

echo "当前用户是:".$s_name;*/



$cj=array(0=>array("1","10"),

1=>array("2","20"),

2=>array("3","30"),

4=>array("4","40"),

);

?>

<html>

<head>

<meta http-equiv="Content-Language" content="en" />

<meta name="GENERATOR" content="PHPEclipse 1.0" />

<meta http-equiv="Content-Type" content="text/html; charset=gbk" />

<title>表格输出数据</title>

</head>

<body bgcolor="#FFFFFF" text="#000000" link="#FF9966" vlink="#FF9966" alink="#FFCC99">

<center>查询结果</center>

<table aglin="center" border="1">

<tr>

<td>学号</td><td>成绩</td>

</tr>

<? for($i=0;$i<count($cj)+1;$i++){?>

<tr>

<td><?echo $cj[$i][0]

?></td><td>

<? echo $cj[$i][1];

?>

</td>

</tr>

<?

}?>

</table>





</body>

</html>







windows中域名映射:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: