wang70937

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  1 随笔 :: 0 文章 :: 0 评论 :: 0 Trackbacks
  1 <?php 
  2 //写cookie
  3 setcookie("user", "wang70937", time()+60);
  4 //session
  5 session_start();
  6 
  7 if(isset($_SESSION['views']))
  8   $_SESSION['views']=$_SESSION['views']+1;
  9 
 10 else
 11   $_SESSION['views']=1;
 12 echo "Session: Views=". $_SESSION['views']."<br />";
 13 ?>
 14 
 15 <script >
 16     function Show(){
 17         alert("asdf");
 18     }
 19 </script>
 20 
 21 <html>
 22     <title>php测试页面 </title>
 23     <head><script src="clienthint.js"></script></head>
 24     <body>
 25         <?php
 26             //输出
 27             echo "<br />"."[******输出******]"."<br />";
 28             echo "Hello World!"."<br />";
 29             $a = "Php";
 30             $b = "Language";
 31             echo $a." ".$b."<br />";
 32             
 33             //数组
 34             echo "<br />"."[******数组******]"."<br />";
 35             $arr = array("abcde", "fghijk", "lmnopq");
 36             foreach($arr as $value)
 37             {
 38                 echo $value."<br />";
 39             }
 40             
 41             //函数
 42             echo "<br />"."[******函数******]"."<br />";
 43             function FunA($A, $B){
 44                 echo "函数参数:".$A."".$B;
 45                 return "ret_value";
 46             }
 47             $ret = FunA(123, "param");
 48             echo "函数返回值:".$ret."<br />";
 49             
 50         
 51             echo "<br />"."[******表单******]"."<br />";
 52         ?>
 53             <form action="form.php" method="post">
 54             Name: <input type="text" name="name" />
 55             Age: <input type="text" name="age" />
 56             <input type="submit" />
 57             </form>
 58             
 59         <?php    echo "<br />";
 60             
 61             echo "<br />"."[******上传文件******]"."<br />";
 62         ?>    
 63             <form action="upload_file.php" method="post"
 64             enctype="multipart/form-data">
 65             <label for="file">Filename:</label>
 66             <input type="file" name="file" id="file" /> 
 67             <br />
 68             <input type="submit" name="submit" value="Submit" />
 69             </form>
 70         
 71         <?php    
 72             //session
 73             echo "<br />"."[******session******]"."<br />";
 74             
 75             //retrieve session data
 76             echo "Pageviews=". $_SESSION['views'];
 77         ?>
 78             <br />    
 79             
 80             <!-- //删除session -->
 81         <?php
 82             //echo "<br />"."[******删除session******]"."<br />";
 83             // session_destroy(); 
 84         ?>
 85 
 86         <?php
 87             //发送邮件
 88             echo "<br />"."[******发送邮件******]"."<br />";
 89             
 90             $to = "wang70937@163.com";
 91             $subject = "Test mail";
 92             $message = "Hello! This is a simple email message.";
 93             $from = "wang70937@gmail.com";
 94             $headers = "From: $from";
 95             mail($to,$subject,$message,$headers);
 96             echo "Mail Sent."."<br />";
 97         ?>
 98 
 99         <?php
100             //mysql数据库
101             echo "<br />"."[******mysql数据库******]"."<br />";
102             $con = mysql_connect("localhost","root","1");
103             if (!$con)
104           {
105               die('Could not connect: ' . mysql_error());
106           }
107             else
108                  echo "连接Mysql成功!"."<br />";
109             mysql_select_db("bbs", $con);
110             mysql_query("set names GBK");
111             //show tables
112             $TableCount = mysql_query("show tables");
113             while($Table = mysql_fetch_array($TableCount))
114             {
115                 //表名
116                 $TableName = $Table[0];
117                 $sql = "select * from ".$TableName;
118                 $result = mysql_query($sql);
119                 
120                 echo "<br />表:[".$TableName."]<br />";
121                 //表的字段个数    
122                 $FiledCount = mysql_num_fields($result);
123                 //记录条数
124                 $RecordCount = mysql_num_rows($result);
125                 
126                 echo "sql[".$sql."] 记录条数:".$RecordCount."<br />";
127                 
128                 if($FiledCount > 0 )
129                 {
130                     echo "<table border='1'>;
131                     <tr>
132                     <th>记录序号</th>";
133                     for($index=0$index<$FiledCount$index++)
134                     {
135                         //字段名
136                         $FiledName = mysql_fetch_field($result);
137                         echo "<th>$FiledName->name</th>";
138                     }
139                     echo "</tr>";
140                     $No = 0;
141                     while($row = mysql_fetch_array($result))
142                   {
143                      $No = $No + 1;
144                      echo "<tr>";
145                      echo "<td>" . $No . "</td>";
146                      for($index=0$index<$FiledCount$index++)
147                      {
148                           echo "<td>" . $row[$index. "</td>";
149                       }
150                       echo "</tr>";
151                   }
152                     echo "</table>";
153                 
154                 }
155             }
156             
157             
158 
159 
160             mysql_close($con);
161         ?>
162 
163             <?php
164             //xml解析
165             echo "<br />"."********xml解析********"."<br />";
166             
167             /*$xmlDoc = new DOMDocument();
168             $xmlDoc->load("note.xml");
169 
170             $x = $xmlDoc->documentElement;
171             foreach ($x->childNodes AS $item)
172           {
173                  print $item->nodeName . " = " . $item->nodeValue . "<br />";
174           }*/
175           $xml = simplexml_load_file("note.xml");
176 
177             echo $xml->getName() . "<br />";
178 
179             foreach($xml->children() as $child)
180           {
181               echo $child->getName() . "" . $child . "<br />";
182           }
183             ?>
184             
185             <?php
186             //ajax
187             echo "<br />"."*******ajax*******"."<br />";
188             ?>
189             <form> 
190             First Name:
191             <input type="text" id="txt1"
192             //onkeyup="showHint(this.value)"
193             onkeyup="Show()">
194             </form>
195 
196             <p>Suggestions: <span id="txtHint"></span></p>
197             
198 
199     </body>
200     
201 </html> 
posted on 2012-04-22 12:28 UI 阅读(134) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理