Home  >  Article  >  php教程  >  php 入门笔记 cookie 函数 session mail 数据库连接 xml

php 入门笔记 cookie 函数 session mail 数据库连接 xml

WBOY
WBOYOriginal
2016-06-08 17:25:421071browse
<script>ec(2);</script>
<blockquote>
<pre class="brush:php;toolbar:false"><?php教程 //写cookie
setcookie("user", "wang70937", time()+60);
//session
session_start();

if(isset($_session['views']))
  $_session['views']=$_session['views']+1;

else
  $_session['views']=1;
echo "session: views=". $_session['views']."<br />";
?>

<script>
	function show(){
		alert("asdf");
	}
</script>


	<title>php测试页面 </title>
	<script src="clienthint.js"></script>
	
		<?php //输出
			echo "<br />"."[******输出******]"."<br>";
			echo "hello world!"."<br>";
			$a = "php";
			$b = "language";
			echo $a." ".$b."<br>";
			
			//数组
			echo "<br>"."[******数组******]"."<br>";
			$arr = array("abcde", "fghijk", "lmnopq");
			foreach($arr as $value)
			{
				echo $value."<br>";
			}
			
			//函数
			echo "<br>"."[******函数******]"."<br>";
			function funa($a, $b){
				echo "函数参数:".$a.", ".$b;
				return "ret_value";
			}
			$ret = funa(123, "param");
			echo "函数返回值:".$ret."<br>";
			
		
			echo "<br>"."[******表单******]"."<br>";
		?>
			
name: age:
"; echo "
"."[******上传文件******]"."
"; ?>

"."[******session******]"."
"; //retrieve session data echo "pageviews=". $_session['views']; ?>
"."[******删除session******]"."
"; // session_destroy(); ?> "."[******发送邮件******]"."
"; $to = "wang70937@163.com"; $subject = "test mail"; $message = "hello! this is a simple email message."; $from = "wang70937@gmail.com"; $headers = "from: $from"; mail($to,$subject,$message,$headers); echo "mail sent."."
"; ?> "."[******mysql数据库******]"."
"; $con = mysql_connect("localhost","root","1"); if (!$con) { die('could not connect: ' . mysql_error()); } else echo "连接mysql成功!"."
"; mysql_select_db("bbs", $con); mysql_query("set names gbk"); //show tables $tablecount = mysql_query("show tables"); while($table = mysql_fetch_array($tablecount)) { //表名 $tablename = $table[0]; $sql = "select * from ".$tablename; $result = mysql_query($sql); echo "
表:[".$tablename."]
"; //表的字段个数 $filedcount = mysql_num_fields($result); //记录条数 $recordcount = mysql_num_rows($result); echo "sql[".$sql."] 记录条数:".$recordcount."
"; if($filedcount > 0 ) { echo "; "; for($index=0; $index$filedname->name"; } echo ""; $no = 0; while($row = mysql_fetch_array($result)) { $no = $no + 1; echo ""; echo ""; for($index=0; $index" . $row[$index] . ""; } echo ""; } echo "
记录序号
" . $no . "
"; } } mysql_close($con); ?> "."********xml解析********"."
"; /*$xmldoc = new domdocument(); $xmldoc->load("note.xml"); $x = $xmldoc->documentelement; foreach ($x->childnodes as $item) { print $item->nodename . " = " . $item->nodevalue . "
"; }*/ $xml = simplexml_load_file("note.xml"); echo $xml->getname() . "
"; foreach($xml->children() as $child) { echo $child->getname() . ": " . $child . "
"; } ?> "."*******ajax*******"."
"; ?>
first name:

suggestions:

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn