本文目錄一覽:
- 1、最簡單 php 代碼
- 2、求一段簡單php代碼
- 3、求很簡單的PHP代碼
- 4、求寫個比較簡單的php登陸頁面代碼
- 5、求php代碼!!!!實現一個簡單的功能。
- 6、php最經典,最基礎的代碼,適合入門的
最簡單 php 代碼
?php
mysql_query(“insert into guahao values(‘”.$name.”‘,'”.$nl.”‘,'”.$shouji.”‘,'”.$sname.”‘,'”.$info.”‘)”);
?
求一段簡單php代碼
?php
echo”開頭”;
for($i=1;$i5;$i++)
{
$b = ‘class’.$i;
echo $b;
}
echo”結尾”;
?
或者
?php
for($i=1;$i5;$i++)
{
if($i==1) echo”開頭”;
$b = ‘class’.$i;
echo $b;
if($i==1) echo”結尾”;
}
?
//這不很簡單嗎
求很簡單的PHP代碼
?php
$folder=”C:\wamp\www\d”;
$fp=opendir($folder);
while(false!=$file=readdir($fp)){
if($file!=’.’ $file!=’..’){
$file=”$folder/$file”;
$arr_file[]=$file;
}
}
if(is_array($arr_file)){
while(list($key,$value)=each($arr_file)){
echo $value;
$key=file_get_contents($value);
$_patten = ‘/(1234567)/’;
if (preg_match($_patten,$key)) {
$a= preg_replace($_patten,”7654321″,$key);
file_put_contents($value, $a);
}
}
}
closedir($fp);
?
代碼就敲到到這了,感覺有點頭痛,正則替換的7654321,你可以定義strrev($1);
求寫個比較簡單的php登陸頁面代碼
index.php 錄入頁代碼form id=”form1″ name=”form1″ method=”post” action=”login.php”
table width=”400″ border=”0″ align=”center” cellpadding=”1″ cellspacing=”1″ class=”tableborder”
tr
tddiv align=”right”用戶名:/div/td
td width=”244″
input type=”text” name=”User_name” id=”User_name” / /td
/tr
tr
tddiv align=”right”密 碼:/div/td
tdinput type=”Password” name=”User_Password” id=”User_Password” //td
/tr
tr
td
div align=”right”
input type=”submit” name=”button” id=”button” value=”提交” /
/div/td
tdinput type=”reset” name=”button2″ id=”button2″ value=”重置” //td
/tr
/table
/form login.php提交頁代碼?
error_reporting(0);
$mysql_servername = “127.0.0.1”;
$mysql_username = “root”;
$mysql_password =”123456″;
$mysql_database =”first”;
mysql_connect($mysql_servername , $mysql_username , $mysql_password);
mysql_select_db($mysql_database);
$U_name=$_POST[‘user_name’];
$U_passowrd=$_POST[‘user_password’];
if ($U_name $U_passowrd){
$sql = “SELECT * FROM admin WHERE U_name = ‘$U_name’ and U_password=’$U_passowrd'”;
$res = mysql_query($sql);
$rows=mysql_num_rows($res);
if($rows){
header(“location=’c.php'”);
exit;
}
echo “script language=javascriptalert(‘用戶名密碼錯誤’);history.back();/script”;
}else {
echo “script language=javascriptalert(‘用戶名密碼不能為空’);history.back();/script”;
}
?
求php代碼!!!!實現一個簡單的功能。
最好不要用中文文件名
?
$content = file_get_contents(‘shuju.txt’);
echo ‘shuju.txt 內容:’.$content;
if(isset($_GET[‘action’])){
if($_GET[‘action’]==1){
file_put_contents(‘open.txt’,”);
echo ‘創建打開.txt’;
}elseif($_GET[‘action’]==2){
file_put_contents(‘close.txt’,”);
echo ‘創建關閉.txt’;
}
}
?
input type=”button” value=”打開” onclick=”window.location=’?action=1′”
input type=”button” value=”關閉” onclick=”window.location=’?action=2′”
php最經典,最基礎的代碼,適合入門的
PHP是一種可以嵌入到HTML中的運行在服務器端的腳本語言,所以為了體現PHP的特性我們可以分兩種模式來實現PHP代碼
1、 PHP嵌入到HTML中,例如index.php
html
head/head
body
!–因為PHP嵌入到HTML中,所以需要完全區分PHP代碼和HTML代碼–
?php
//輸出hello world
echo ‘hello world;
?
/body
/html
2、 PHP獨立文件,只有PHP代碼,例如index.php
?php
//輸出
echo ‘hello world’;
//不需要閉合標籤
原創文章,作者:0YJHI,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/130874.html