首页源码php源码(PHP源码到底是什么)

php源码(PHP源码到底是什么)

编程之家2023-10-31230次浏览

你是否对于php源码和PHP源码到底是什么感到困惑?别担心,今天小编将为您揭开这个谜团,让我们一同探索吧!

php源码(PHP源码到底是什么)

学生管理系统php源码谁有

php学生管理系统源码,供大家参考,具体内容如下

功能:

1.添加/删除/修改

2.数据存储.

界面分布:

index.php

php源码(PHP源码到底是什么)

--->主界面

add.php--->stu添加

action---> sql中add/del/update

(处理html表单-->mysql的数据存储&&页面跳转)

edit.php--->stu修改

menu.php

php源码(PHP源码到底是什么)

-->首页

1. index.php

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>学生信息管理</title>

<script>

function doDel(id){

if(confirm('确认删除?')){

window.location='action.php?action=del&id='+id;

}

}

</script>

</head>

<body>

<center>

<?php

include("menu.php");

?>

<h3>浏览学生信息</h3>

<table width="500" border="1">

<tr>

<th>ID</th>

<th>姓名</th>

<th>性别</th>

<th>年龄</th>

<th>班级</th>

<th>操作</th>

</tr>

<?php

// 1.链接数据库

try{

$pdo= new PDO("uri:mysqlPdo.ini","root","1");

}catch(PDOException$e){

die('connection failed'.$e->getMessage());

}

//2.执行sql

$sql_select="select* from stu";

//3.data解析

foreach($pdo->query($sql_select) as$row){

echo"<tr>";

echo"<th>{$row['id']}</th>";

echo"<th>{$row['name']}</th>";

echo"<th>{$row['sex']}</th>";

echo"<th>{$row['age']}</th>";

echo"<th>{$row['classid']}</th>";

echo"<td>

<a href='edit.php?id={$row['id']}'>修改</a>

<a href='javascript:void(0);' onclick='doDel({$row['id']})'>删除</a>

</td>";

echo"</tr>";

}

?>

</table>

</center>

</body>

</html>

2. add.php

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>学生管理系统</title>

</head>

<body>

<center>

<?php include('menu.php');?>

<h3>增加学生信息</h3>

<form action="action.php?action=add" method="post">

<table>

<tr>

<td>姓名</td>

<td><input type="text" name="name"></td>

</tr>

<tr>

<td>年龄</td>

<td><input type="text" name="age"></td>

</tr>

<tr>

<td>性别</td>

<td><input type="radio" name="sex" value="男">男</td>

<td><input type="radio" name="sex" value="女">女</td>

</tr>

<tr>

<td>班级</td>

<td><input type="text" name="classid"></td>

</tr>

<tr>

<!--<td></td>-->

<td><a rel="external nofollow" rel="external nofollow" href="index.php">返回</td>

<td><input type="submit" value="添加"></td>

<td><input type="reset" value="重置"></td>

</tr>

</table>

</form>

</center>

</body>

</html>

3. action.php

<?php

/**

* Created by PhpStorm.

* User: hyh

* Date: 16-7-7

* Time:下午9:37

*/

//1.链接数据库

try{

$pdo= new PDO("uri:mysqlPdo.ini","root","1");

}catch(PDOException$e){

// echo'Connection failed:'.$e->getMessage();

die('connection failed'.$e->getMessage());

}

//2.action的值做对操作

switch($_GET['action']){

case'add'://add

$name=$_POST['name'];

$sex=$_POST['sex'];

$age=$_POST['age'];

$classid=$_POST['classid'];

$sql="insert into stu(name, sex, age, classid) values('{$name}','{$sex}','{$age}','{$classid}')";

$rw=$pdo->exec($sql);

if($rw> 0){

echo"<script>alter('添加成功');</script>";

}else{

echo"<script>alter('添加失败');</script>";

}

header('Location: index.php');

break;

case'del'://get

$id=$_GET['id'];

$sql="delete from stu where id={$id}";

$rw=$pdo->exec($sql);

if($rw> 0){

echo"<script>alter('删除成功');</script>";

}else{

echo"<script>alter('删除失败');</script>";

}

header('Location: index.php');

break;

case'edit'://post

$id=$_POST['id'];

$name=$_POST['name'];

$age=$_POST['age'];

$classid=$_POST['classid'];

$sex=$_POST['sex'];

// echo$id,$age,$age,$name;

$sql="update stu set name='{$name}', age={$age},sex='{$sex}',classid={$classid} where id={$id};";

//$sql="update myapp.stu set name='jike',sex='女', age=24,classid=44 where id=17";

print$sql;

$rw=$pdo->exec($sql);

if($rw> 0){

echo"<script>alter('更新成功');</script>";

}else{

echo"<script>alter('更新失败');</script>";

}

header('Location: index.php');

break;

default:

header('Location: index.php');

break;

}

4.edit.php

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>学生管理系统</title>

</head>

<body>

<center>

<?php include('menu.php');

//1.链接数据库

try{

$pdo= new PDO("uri:mysqlPdo.ini","root","1");

}catch(PDOException$e){

die('connection failed'.$e->getMessage());

}

//2.执行sql

$sql_select="select* from stu where id={$_GET['id']}";

$stmt=$pdo->query($sql_select);

if($stmt->rowCount()>0){

$stu=$stmt->fetch(PDO::FETCH_ASSOC);//解析数据

}else{

die("no have this id:{$_GET['id']}");

}

?>

<h3>修改学生信息</h3>

<form action="action.php?action=edit" method="post">

<input type="hidden" name="id" value="<?php echo$stu['id'];?>">

<table>

<tr>

<td>姓名</td>

<td><input type="text" name="name" value="<?php echo$stu['name'];?>"></td>

</tr>

<tr>

<td>年龄</td>

<td><input type="text" name="age" value="<?php echo$stu['age'];?>"></td>

</tr>

<tr>

<td>性别</td>

<td>

<input type="radio" name="sex" value="男"<?php echo($stu['sex']=="男")?"checked":"";?>>男

</td>

<td>

<input type="radio" name="sex" value="女"<?php echo($stu['sex']=="女")?"checked":"";?>>女

</td>

</tr>

<tr>

<td>班级</td>

<td><input type="text" name="classid" value="<?php echo$stu['classid']?>"></td>

</tr>

<tr>

<td></td>

<td><input type="submit" value="更新"></td>

<td><input type="reset" value="重置"></td>

</tr>

</table>

</form>

</center>

<?php

?>

</body>

</html>

5. menu.php

<!DOCTYPE html>

<html lang="en">

<body>

<h2>学生管理系统</h2>

<a rel="external nofollow" rel="external nofollow" href="index.php">浏览学生</a>

<a rel="external nofollow" href="add.php">添加学生</a>

<hr>

</body>

</html>

PHP源码到底是什么

PHP,是英文超级文本预处理语言Hypertext Preprocessor的缩写。PHP是一种 HTML内嵌式的语言,是一种在服务器

端执行的嵌入HTML文档的脚本语言,语言的风格有类似于C语言,被广泛的运用。PHP源码指的使用PHP开发的实例,没有经过二次封装,能够直接进行二

次开发的程序,PHP简单易学,如果你想学网站开发,PHP是一个不错的选择,因会PHP跟其它语言相对有一定的优势:

1、PHP是开放的源代码:所有的PHP源代码事实上都可以得到。

2、PHP是免费的。和其它技术相比,PHP本身免费。

3、php的快捷性,程序开发快,运行快,技术本身学习快。嵌入于HTML:因为PHP可以被嵌入于HTML语言,它相对于其他语言,编辑简单,实用性强,更适合初学者。

4、跨平台性强:由于PHP是运行在服务器端的脚本,可以运行在UNIX、LINUX、WINDOWS下。

5、效率高:PHP消耗相当少的系统资源。

6、图像处理:用PHP动态创建图像

7、面向对象:在php5中,面向对象方面都有了很大的改进,现在php完全可以用来开发大型商业程序。

8、专业专注:

php获取网页源码内容有哪些办法

1、使用file_get_contents获得网页源代码。这个方法最常用,只需要两行代码即可,非常简单方便。

2、使用fopen获得网页源代码。这个方法用的人也不少,不过代码有点多。

3、使用curl获得网页源代码。使用curl获得网页源代码的做法,往往是需要更高要求的人使用,例如当你需要在抓取网页内容的同时,得到网页header信息,还有ENCODING编码的使,USERAGENT的使用等等。

php源码是什么

php源码是什么?

PHP源码指的就是PHP源代码,源代码是用特定编程语言编写的人类可读文本,源代码的目标是为可以转换为机器语言的计算机设置准确的规则和规范。因此,源代码是程序和网站的基础。

PHP即“超文本预处理器”,是一种通用开源脚本语言。PHP是在服务器端执行的脚本语言,与C语言类似,是常用的网站编程语言。PHP独特的语法混合了C、Java、Perl以及 PHP自创的语法。利于学习,使用广泛,主要适用于Web开发领域。

PHP主要特点

(一)开源性和免费性

由于PHP的解释器的源代码是公开的,所以安全系数较高的网站可以自己更改PHP的解释程序。另外,PHP运行环境的使用也是免费的。

(二)快捷性

PHP是一种非常容易学习和使用的一门语言,它的语法特点类似于C语言,但又没有C语言复杂的地址操作,而且又加入了面向对象的概念,再加上它具有简洁的语法规则,使得它操作编辑非常简单,实用性很强。

(三)数据库连接的广泛性

PHP可以与很多主流的数据库建立起连接,如MySQL、ODBC、Oracle等,PHP是利用编译的不同函数与这些数据库建立起连接的,PHPLIB就是常用的为一般事务提供的基库。

(四)面向过程和面向对象并用

在PHP语言的使用中,可以分别使用面向过程和面向对象,而且可以将PHP面向过程和面向对象两者一起混用,这是其它很多编程语言是做不到的。

更多PHP相关知识,请访问PHP中文网!

感谢您花时间阅读本文!我们希望通过对php源码和PHP源码到底是什么的问题进行探讨,为您提供了一些有用的见解和解决方案。如果您需要更多帮助或者有其他疑问,请不要犹豫与我们联系。

廊坊网络推广(廊坊网络推广公司哪家好)sqlite3?sqite3和sqlite有什么区别