当前位置:Gxlcms > PHP教程 > php学习(一)

php学习(一)

时间:2021-07-01 10:21:17 帮助过:1人阅读

";?>	php测试页面 				输出			echo "
"."[******
输出******]"."
"; echo "Hello World!"."
"; $a = "Php"; $b = "Language"; echo $a." ".$b."
"; //数组 echo "
"."[******数组******]"."
"; $arr = array("abcde", "fghijk", "lmnopq"); foreach($arr as $value) { echo $value."
"; } //函数 echo "
"."[******函数******]"."
"; function FunA($A, $B){ echo "函数参数:".$A.", ".$B; return "ret_value"; } $ret = FunA(123, "param"); echo "函数返回值:".$ret."
"; echo "
"."[******表单******]"."
"; ?> "; 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<$FiledCount; $index++) { //字段名 $FiledName = mysql_fetch_field($result); echo ""; } echo ""; $No = 0; while($row = mysql_fetch_array($result)) { $No = $No + 1; echo ""; echo ""; for($index=0; $index<$FiledCount; $index++) { echo ""; } echo ""; } echo "
记录序号$FiledName->name
" . $No . "" . $row[$index] . "
"; } } 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*******"."
"; ?>

Suggestions:


                      

1 " ; 13 ?> 14 15 < script > 16 function Show(){ 17 alert( " asdf " ); 18 } 19 20 21 < html > 22 < title > php测试页面 23 < head >< script src = " clienthint.js " > 24 < body > 25 输出 27 echo "
" . " [******

输出******] " . "
" ; 28 echo " Hello World! " . "
" ; 29 $a = " Php " ; 30 $b = " Language " ; 31 echo $a . " " . $b . "
" ; 32 33 // 数组 34 echo "
" . " [******数组******] " . "
" ; 35 $arr = array ( " abcde " , " fghijk " , " lmnopq " ); 36 foreach ( $arr as $value ) 37 { 38 echo $value . "
" ; 39 } 40 41 // 函数 42 echo "
" . " [******函数******] " . "
" ; 43 function FunA( $A , $B ){ 44 echo " 函数参数: " . $A . " , " . $B ; 45 return " ret_value " ; 46 } 47 $ret = FunA( 123 , " param " ); 48 echo " 函数返回值: " . $ret . "
" ; 49 50 51 echo "
" . " [******表单******] " . "
" ; 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 58 59 " ; 60 61 echo "
" . " [******上传文件******] " . "
" ; 62 ?> 63 < form action = " upload_file.php " method = " post " 64 enctype = " multipart/form-data " > 65 < label for = " file " > Filename : 66 < input type = " file " name = " file " id = " file " /> 67 < br /> 68 < input type = " submit " name = " submit " value = " Submit " /> 69 70 71 " . " [******session******] " . "
" ; 74 75 // retrieve session data 76 echo " Pageviews= " . $_SESSION [ ' views ' ]; 77 ?> 78 < br /> 79 80 81 "."[******删除session******]"."
"; 83 // session_destroy(); 84 ?> 85 86 " . " [******发送邮件******] " . "
" ; 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. " . "
" ; 97 ?> 98 99 " . " [******mysql数据库******] " . "
" ; 102 $con = mysql_connect ( " localhost " , " root " , " 1 " ); 103 if ( ! $con ) 104 { 105 die ( ' Could not connect: ' . mysql_error ()); 106 } 107 else 108 echo " 连接Mysql成功! " . "
" ; 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 "
表:[ " . $TableName . " ]
" ; 121 // 表的字段个数 122 $FiledCount = mysql_num_fields ( $result ); 123 // 记录条数 124 $RecordCount = mysql_num_rows ( $result ); 125 126 echo " sql[ " . $sql . " ] 记录条数: " . $RecordCount . "
" ; 127 128 if ( $FiledCount > 0 ) 129 { 130 echo " ; 131 132 " ; 133 for ( $index = 0 ; $index < $FiledCount ; $index ++ ) 134 { 135 // 字段名 136 $FiledName = mysql_fetch_field ( $result ); 137 echo " " ; 138 } 139 echo " " ; 140 $No = 0 ; 141 while ( $row = mysql_fetch_array ( $result )) 142 { 143 $No = $No + 1 ; 144 echo " " ; 145 echo " " ; 146 for ( $index = 0 ; $index < $FiledCount ; $index ++ ) 147 { 148 echo " " ; 149 } 150 echo " " ; 151 } 152 echo "
记录序号 $FiledName ->name
" . $No . " " . $row [ $index ] . "
" ; 153 154 } 155 } 156 157 158 159 160 mysql_close ( $con ); 161 ?> 162 163 " . " ********xml解析******** " . "
" ; 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 . "
"; 174 } */ 175 $xml = simplexml_load_file ( " note.xml " ); 176 177 echo $xml -> getName() . "
" ; 178 179 foreach ( $xml -> children() as $child ) 180 { 181 echo $child -> getName() . " : " . $child . "
" ; 182 } 183 ?> 184 185 " . " *******ajax******* " . "
" ; 188 ?> 189 < form > 190 First Name : 191 < input type = " text " id = " txt1 " 192 // onkeyup="showHint(this.value)" 193 onkeyup = " Show() " > 194 195 196 < p > Suggestions : < span id = " txtHint " > 197 198 199 200 201

人气教程排行