cookie 函数 session mail 数据库连接 xml
发布:smiling 来源: PHP粉丝网 添加日期:2014-08-05 15:00:24 浏览: 评论:0
- <?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>
- <html>
- <title>php测试页面 </title>
- <head><script src="clienthint.js"></script></head>
- <body>
- <?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 />";
- ?>
- <form action="form.php" method="post">
- name: <input type="text" name="name" />
- age: <input type="text" name="age" />
- <input type="submit" />
- </form>
- <?php echo "<br />";
- echo "<br />"."[******上传文件******]"."<br />";
- ?>
- <form action="upload_file.php" method="post"
- enctype="multipart/form-data">
- <label for="file">filename:</label>
- <input type="file" name="file" id="file" />
- <br />
- <input type="submit" name="submit" value="submit" />
- </form>
- <?php
- //session
- echo "<br />"."[******session******]"."<br />";
- //retrieve session data
- echo "pageviews=". $_session['views'];
- ?>
- <br />
- <!-- //删除session -->
- <?php
- //echo "<br />"."[******删除session******]"."<br />";
- // session_destroy();
- ?>
- <?php
- //发送邮件
- echo "<br />"."[******发送邮件******]"."<br />";
- $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."."<br />";
- ?>
- <?php
- //mysql教程数据库教程
- echo "<br />"."[******mysql数据库******]"."<br />";
- $con = mysql_connect("localhost","root","1");
- if (!$con)
- {
- die('could not connect: ' . mysql_error());
- }
- else
- echo "连接mysql成功!"."<br />";
- 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 "<br />表:[".$tablename."]<br />";
- //表的字段个数
- $filedcount = mysql_num_fields($result);
- //记录条数
- $recordcount = mysql_num_rows($result);
- echo "sql[".$sql."] 记录条数:".$recordcount."<br />";
- if($filedcount > 0 )
- {
- echo "<table border='1'>;
- <tr>
- <th>记录序号</th>";
- for($index=0; $index<$filedcount; $index++)
- {
- //字段名
- $filedname = mysql_fetch_field($result);
- echo "<th>$filedname->name</th>";
- }
- echo "</tr>";
- $no = 0;
- while($row = mysql_fetch_array($result))
- {
- $no = $no + 1;
- echo "<tr>";
- echo "<td>" . $no . "</td>";
- for($index=0; $index<$filedcount; $index++)
- {
- echo "<td>" . $row[$index] . "</td>";
- }
- echo "</tr>";
- }
- echo "</table>";
- }
- }
- mysql_close($con);
- ?>
- <?php
- //xml解析
- echo "<br />"."********xml解析********"."<br />";
- /*$xmldoc = new domdocument();
- $xmldoc->load("note.xml");
- $x = $xmldoc->documentelement;
- foreach ($x->childnodes as $item)
- {
- print $item->nodename . " = " . $item->nodevalue . "<br />";
- }*/
- $xml = simplexml_load_file("note.xml");
- echo $xml->getname() . "<br />";
- foreach($xml->children() as $child)
- {
- echo $child->getname() . ": " . $child . "<br />";
- }
- ?>
- <?php
- //ajax
- echo "<br />"."*******ajax*******"."<br />";
- ?>
- <form>
- first name:
- <input type="text" id="txt1"
- //onkeyup="showhint(this.value)"
- onkeyup="show()">
- </form>
- <p>suggestions: <span id="txthint"></span></p>
- </body>
- </html>
Tags: cookie 函数 session mail
相关文章
- ·php简单设置与删除cookie代码(2013-11-13)
- ·session与cookie会话控制(2013-11-14)
- ·cookie和session 区别(2013-11-14)
- ·php setcookie值为null或空字符串删除cookie解析(2013-12-04)
- ·php不同子域的同名cookie问题解决方法(2013-12-07)
- ·php cookie 读取 设置 删除实例(2013-12-19)
- ·php cookie登录验证代码(2013-12-27)
- ·php利用cookie防止重复提交解决办法(2013-12-27)
- ·php中利用cookie实现购物车实例(2014-01-11)
- ·PHP如何读取COOKIES(2014-01-14)
- ·php $_COOKIE简单应用实例(2014-01-15)
- ·php cookies 删除,赋值方法(2014-01-15)
- ·php cookie工作原理与cookie实例详解(2014-01-18)
- ·正确理解cookie和session机制原理(2014-02-10)
- ·php中cookie与session应用学习笔记(2014-02-10)
- ·php cookie方法学习笔记分享(2014-02-16)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)