您的位置:

php大作业含代码,php大作业总结

本文目录一览:

求大神帮忙写个php代码

?php

/**

* **********************************************************

* Read Me

* 文章分页

*

* 分页方式,可以按字数分页,按换行分页,按特殊标记分页等

* 其实实现思路是一样的,只是将其按一定规律放入一个数组

* 然后根据 url 传入的参数取得某个片段即可

* 大家完全可以写一个功能强大的函数保存起来以备不时之需

*

*/

header('Content-Type:text/html; charset=utf-8');

?

?php

$title = 'Pagination Test';

//需要分页的数据

$data = DATA

Hey, guys. I am here to test if it is working.

This pagination is very simple, isn't it?!--pagination--

And I tried to use different method to page it.

Can you see it?

DATA;

//当前文章页

$page = 0;

//初始文章长度

$length = 0;

//分页长度

$perpage = 160;

//显示在页面的代码

$link = '';

//分割后的数组

$strArr = array();

$page = isset($_GET['page']) ? intval($_GET['page']) : 0;

$length = strlen($data);

//按字数分割

// $str = str_split($data, $perpage);

//按字符分割

$delimiter = "\n";

// $delimiter = '--pagination--';

$strArr = explode($delimiter, $data);

$strNum = count($strArr);

$content = $strArr[$page];

if ($strNum 1) {

if ($page != 0) {

$link .= 'a href="?page=0"首页/a';

} else {

$link .= 'span首页/span';

}

for ($n = 0; $n $strNum; $n++) {

if ($n == $page) {

$link .= 'span' . ($n + 1) . '/span';

} else {

$link .= "a href='?page={$n}'" . ($n + 1) . "/a";

}

}

$link .= '';

if ($page != ($strNum - 1)) {

$link .= "a href='?page=" . ($strNum - 1) . "'尾页/a";

} else {

$link .= 'span尾页/span';

}

}

?

!DOCTYPE HTML

html lang="en-US"

head

meta charset="UTF-8"

style type="text/css"

body {

font-family: '微软雅黑';

}

.link a, span {

margin: 1px;

padding: 1px;

}

.link span {

color: #777;

}

.link a {

color: #26A2DA;

text-decoration: none;

}

/style

title测试文章分页/title

/head

body

h1?php echo $title; ?/h1

p?php echo $content; ?/p

hr /

p class="link"?php echo $link; ?/p

/body

/html

求一份PHP大作业 php+mySQL网页制作留言板 简单点的 能运行就好....: 谢谢

给你提个思路吧,简单的,你自己举一返三,代码现写懒,表单form里面一个文本框,一个提交按钮,提交的的事件中连接数据库,读取文本框值insert into到对应的表里面就完了。

PHP程序代码

?php

if(!defined('CORE_ROOT')) exit();

require CORE_ROOT.'include/admin.inc.php';

require_once CORE_ROOT.'include/image.func.php';

if(isset($_SERVER['HTTP_CONTENT_DISPOSITION'])  preg_match('/attachment;\s+name="(.+?)";\s+filename="(.+?)"/i',$_SERVER['HTTP_CONTENT_DISPOSITION'], $info)){

$filename = fromutf8(urldecode($info[2]));

if(fileext($filename) == 'php') aexit();

$newfilename = get_upload_filename($filename, 0, 0, 'image');

$a = file_get_contents("php://input");

if(!checkuploadfile($a)) {

uploaddanger($lan['danger']);

} else {

writetofile($a, FORE_ROOT.$newfilename);

}

} else {

$uptype = 'image';

if(isset($get_attach)) $uptype = 'attach';

$filename = $file_filedata['name'];

if(fileext($filename) == 'php') aexit();

if(!empty($get_utf8)) $filename = fromutf8($filename);

$newfilename = get_upload_filename($filename, 0, 0, $uptype);

uploadfile($file_filedata['tmp_name'], FORE_ROOT.$newfilename);

$piccontent = file_get_contents(FORE_ROOT.$newfilename);

if(!checkuploadfile($piccontent)) {

akunlink(FORE_ROOT.$filename);

uploaddanger($lan['danger']);

}

}

$modules = getcache('modules');

if(ispicture($filename)) operateuploadpicture(FORE_ROOT.$newfilename, $modules[akgetcookie('lastmoduleid')]);

$picurl = $homepage.$newfilename;

$insertarray = array('itemid' = $get_id, 'filename' = $newfilename, 'ispicture' = 1, 'filesize' = filesize(FORE_ROOT.$newfilename), 'dateline' = $thetime, 'originalname' = $filename);

if(isset($get_attach)) $insertarray['ispicture'] = 0;

$db-insert('attachments', $insertarray);

$count = $db-get_by('COUNT(*)', 'attachments', "itemid='$get_id'");

$db-update('items', array('attach' = $count), "id='$get_id'");

$msg = "{'url':'".$picurl."','localname':'".$newfilename."','id':'1'}";

aexit("{'err':'','msg':".$msg."}");

function uploaderror($msg) {

aexit("{'err':'','msg':".$msg."}");

}

function uploaddanger($msg) {

uploaderror($msg);

}

?

在线求一个PHP网页源代码 ``(为了完成作业)

一楼的不要蒙人啊。

下面是一个远程修改ftp密码的php程序,你交上去,一定非常好。

不仅包含有html知识,也有js验证,还有php知识。如果你今后做网站,这个程序对你也非常实用。

?PHP

if($_POST['servername']){

function jsalert($w)

{

echo 'script language="javascript"alert("'.$w.'");'."\r\n";

echo 'window.history.go(-1)';

echo '/script';

}

if(!$_POST['UserName']){jsalert('Username error');exit;}

if(!($fp=@ftp_connect($_POST['servername'])))

{

jsalert( $_POST['servername'].'server can not connect!');

exit();

}

if(!@ftp_login($fp,$_POST['UserName'],$_POST['OldPassWord']))

{

jsalert('Sorry, you entered an incorrect username or password!');

exit();

}

if(@ftp_site($fp,'pswd '.$_POST['OldPassWord'].' '.$_POST['NewPassWord']))

{

jsalert('OK, the password has been successfully changed.');

exit;

}

else

{

jsalert('Failure, may be the FTP server does not support the change。');

exit;

}

}

else{

?

html

head

titleFTP password online tools to change/title

script language="JavaScript"

function is_kuho_password(password){

var pattern = /^([a-zA-Z0-9])+$/;

var flag= pattern.test(password);

if(!flag){return false;}

return true;

}

function passchange(){

var servername = document.passwdchange.servername.value;

var UserName = document.passwdchange.UserName.value;

var OldPassWord = document.passwdchange.OldPassWord.value;

var NewPassWord = document.passwdchange.NewPassWord.value;

var NewPassWord1 = document.passwdchange.NewPassWord1.value;

if(!servername){

alert('Please input domain name or ip');

document.passwdchange.servername.focus();

document.passwdchange.servername.value='';

return false;

}

if(!UserName){

alert('Please input user name');

document.passwdchange.UserName.focus();

document.passwdchange.UserName.value='';

return false;

}

//check PassWord

if(!OldPassWord){

alert('Please input password');

document.passwdchange.OldPassWord.focus();

document.passwdchange.OldPassWord.value='';

return false;

}

if(!NewPassWord){

alert('Please input new password');

document.passwdchange.NewPassWord1.value='';

document.passwdchange.NewPassWord.focus();

document.passwdchange.NewPassWord.value='';

return false;

}

if(!is_kuho_password(NewPassWord)){

alert('Sorry! You do not regulate the new password! Please enter from the 6-20 letters or numbers in Password!');

document.passwdchange.NewPassWord1.value='';

document.passwdchange.NewPassWord.focus();

document.passwdchange.NewPassWord.value='';

return false;

}

if(NewPassWord.length 6 || NewPassWord.length 20 ){

alert('You enter a new password length is not in line with the norms, enter the password 6-20 bit!');

document.passwdchange.NewPassWord1.value='';

document.passwdchange.NewPassWord.focus();

document.passwdchange.NewPassWord.value='';

return false;

}

if(!NewPassWord1){

alert('Make sure your new password!');

document.passwdchange.NewPassWord1.focus();

document.passwdchange.NewPassWord1.value='';

return false;

}

if(!is_kuho_password(NewPassWord1)){

alert('Sorry! You do not regulate the new password! Please enter from the 6-20 letters or numbers in Password!');

document.passwdchange.NewPassWord1.focus();

document.passwdchange.NewPassWord1.value='';

return false;

}

if( NewPassWord1.length 6 || NewPassWord1.length 20 ){

alert('Sorry! You do not regulate the new password! Please enter from the 6-20 letters or numbers in Password!');

document.passwdchange.NewPassWord1.focus();

document.passwdchange.NewPassWord1.value='';

return false;

}

if(NewPassWord != NewPassWord1){

alert('You enter the new password twice inconsistent, please re-enter after the check!');

document.passwdchange.NewPassWord1.value='';

document.passwdchange.NewPassWord.focus();

document.passwdchange.NewPassWord.value='';

return false;

}

if(NewPassWord == OldPassWord){

alert('The new password and the old password, no need to change!');

document.passwdchange.NewPassWord1.value='';

document.passwdchange.NewPassWord.focus();

document.passwdchange.NewPassWord.value='';

return false;

}

document.passwdchange.Submit.value="Being change...";

document.passwdchange.Submit.disabled=true;

}

/SCRIPT

/head

body

div align="center"

center

TABLE cellSpacing=1 cellPadding=8 width="600" bgColor=#635139 border=0

FORM name=passwdchange target="_self" action=?php echo $_SERVER['PHP_SELF']; ? onsubmit="return passchange()" method=post

TBODY

tr

TD align=center bgColor=#FFFFFF colspan="2"font color="#FF9933"b

FTP password online tools to change/b/font/TD

/tr

tr

TD align=right bgColor=#d6d3d6 width="154"Sever name:/TD

TD align=left bgColor=#ffffff width="411"INPUT style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: 1px solid; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #484800; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #ffffff"

maxLength=16 name=servername size="20"FONT class=color1 font color="#FF9933"

* Domain name or IP address/font/FONT/TD

/tr

TR height=30

TD align=right bgColor=#d6d3d6 width="154"User name:/TD

TD align=left bgColor=#ffffff width="411"INPUT

style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: 1px solid; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #484800; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #ffffff"

maxLength=16 name=UserName size="20"FONT class=color1 font color="#FF9933"

*/font/FONT/TD/TR

TR height=30

TD align=right bgColor=#d6d3d6 width="154"Password:/TD

TD align=left bgColor=#ffffff width="411"INPUT

style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: 1px solid; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #484800; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #ffffff"

type=password maxLength=16 name=OldPassWord size="20"FONT

class=color1 font color="#FF9933"*/font/FONT/TD/TR

TR height=30

TD align=right bgColor=#d6d3d6 width="154"New password:/TD

TD align=left bgColor=#ffffff width="411"INPUT

style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; COLOR: #484800; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #ffffff"

type=password maxLength=16 name=NewPassWord size="20"FONT

class=color1 font color="#FF9933"*/font/FONT (Length:6-16bit) /TD/TR

TR height=30

TD align=right bgColor=#d6d3d6 width="154"Replay new password:/TD

TD align=left bgColor=#ffffff width="411"INPUT

style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: 1px solid; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #484800; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #ffffff"

type=password maxLength=16 name=NewPassWord1 size="20"FONT

class=color1 font color="#FF9933"*/font/FONT/TD/TR

TR

TD class=huangz align=middle bgColor=#ffffff colSpan=2 height=30 width="504"

p align="center"INPUT type=submit value=Change name=Submit/p

/TD/TR/FORM

/table

/center

/div

/body

/html

?php } ?

求一个php期末大作业的源码(包括素材) ,可以实现增删改查功能就可以

。。如果没有其他要求,你只要:

①安装环境,如集成xmapp

②自己随便建个表,没其他需求俩字段就够了。

③下个yii源码包,用自带gii工具生成一套crud。

over。

关于PHP代码几道问题,求大神给出源代码~~

header('content-type:text/html;charset=utf-8');

1(1)先输出该字符串,然后将该字符串转化成数组,并输出该数组;

$str="123456789";//自定义的字符串

echo $str."br /";

$arr=explode($str);

var_dump($arr);

1(2)统计该数组长度,并输出其中的最大值、最小值;

$length=count($arr);//统计数组单元个数

echo max($arr);

echo min($arr);

1(3)按候选人编号从小到大的顺序排列

$newArr=asort($arr);

foreach ($newArr as $k=$v){

   echo $v."号候选人,得票为".$k."br /";

}

2(1)输入:任意整数(表示若干天后)

$add_day=5;//若干天 暂定5天

2(2)输出:显示任意天数以后的具体日期,以及那一天是星期几。

$date=date("Y-m-d H:i:s",time()+$add_day*24*3600);

$w=date("w",time()+5*24*3600);

if ($w == 0) {

$w='日';

}

echo $date.' 今天是周'.$w;

3(1)输入:5个分数

3(2)输出:去掉一个最高分和去掉一个最低分后的平均分,保留2位小数。

function abc($str){

        $str="85,45.5,35,46,90";

        $arr=explode($str);

foreach ($arr as $k=$v){

if ($v != max($arr)  $k !=min($arr)) {

$success+=$v;

}

}

$result=$success/3;

return round($result,2);

}

好累。