1
0
Fork 0
This commit is contained in:
Chenx221 2024-01-10 12:40:46 +08:00
parent 9165377640
commit 5884da9ce9
39 changed files with 565 additions and 0 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

14
.idea/deployment.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" serverName="wamp" remoteFilesAllowedToDisappearOnAutoupload="false">
<serverData>
<paths name="wamp">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/php/" />
</mappings>
</serverdata>
</paths>
</serverData>
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/php.iml" filepath="$PROJECT_DIR$/.idea/php.iml" />
</modules>
</component>
</project>

8
.idea/php.iml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

20
.idea/php.xml Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MessDetectorOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCSFixerOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCodeSnifferOptionsConfiguration">
<option name="highlightLevel" value="WARNING" />
<option name="transferred" value="true" />
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.2" />
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" />
</component>
</project>

10
.idea/webServers.xml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WebServers">
<option name="servers">
<webServer id="e51e86be-c324-48be-a657-84abdcd21bd8" name="wamp" url="http://localhost:8080">
<fileTransfer accessType="LOCAL" port="0" />
</webServer>
</option>
</component>
</project>

11
2.test1.php Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test1</title>
</head>
<body>
<?php
echo "hello world";
?>
</body>

11
2.work1.php Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test1</title>
</head>
<body>
<?php
echo "恭喜您走上PHP的编程之路";
?>
</body>

13
2.work2.php Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test1</title>
</head>
<body>
<?php
echo '<table><tr><td style="height: 50px;width: 50px">1</td><td style="height: 50px;width: 50px">2</td><td style="height: 50px;width: 50px">3</td></tr><tr><td style="height: 50px;width: 50px">4</td><td style="height: 50px;width: 50px">5</td><td style="height: 50px;width: 50px">6</td></tr><tr><td style="height: 50px;width: 50px">7</td><td style="height: 50px;width: 50px">8</td><td style="height: 50px;width: 50px">9</td></tr><tr><td style="height: 50px;width: 50px">10</td><td style="height: 50px;width: 50px">11</td><td style="height: 50px;width: 50px">12</td></tr></table>';
?>
</body>

16
3.test1.php Normal file
View File

@ -0,0 +1,16 @@
<?php
//注释
echo "xml风格"; //注释2
echo "hello world" # 测试
/*
测试
测试
*/
/*
* 测试
*
*
* */
?>

8
3.test2.php Normal file
View File

@ -0,0 +1,8 @@
<?php
$boo = false;
if ($boo)
echo "变量$boo 为真";
else
echo "变量$boo 为假";

13
3.test3.php Normal file
View File

@ -0,0 +1,13 @@
<?php
$str1 = "这是一个字符串";
echo "$str1";
echo '$str1<p>';
echo <<< str
输出输出<p>
\$str1的内容是$str1
str;

22
3.test4.php Normal file
View File

@ -0,0 +1,22 @@
<?php
$str1 = 1234567890;
$str2 = 0x1234567890;
$str3 = 0123456;
$str4 = 01234567;
echo '$str1的值为'.$str1."<br>";
echo '$str2的值为'.$str2."<br>";
echo '$str3与$str4的关系是';
if($str3==$str4)
echo '$str3==$str4='.$str3;
else
echo '$str3!=$str4';
echo "<p>";
$str5 = pi();
$str6 = 3.1415926;
$str7 = 31415926E-7;
echo "\$str5:".$str5."<p>";
echo "\$str6:".$str6."<p>";
echo "\$str7:".$str7."<p>";
$arr1 = array('1','2','3','4','5');
$arr2 = array(0 => '1',1 =>'2');
$arr3[1] = 'temp';

10
3.test5.php Normal file
View File

@ -0,0 +1,10 @@
<?php
define("MESSAGE","你好世界");
echo MESSAGE."<p>";
$str1 = "MESSAGE";
echo constant($str1);
echo defined("MESSAGE")."<p>";
echo __FILE__."<p></p>".__LINE__."<p></p>".PHP_VERSION."<br>".PHP_OS."<p></p>";
echo $_SERVER['SERVER_ADDR'];

11
3.work1.php Normal file
View File

@ -0,0 +1,11 @@
<?php
$input_content = "12345678901234567890123456";
function check($input): void
{
if (is_numeric($input) && strlen($input) <= 25 && !is_null($input))
echo "数据符合要求";
else
echo "数据不符合要求";
}
check($input_content);

2
3.work2.php Normal file
View File

@ -0,0 +1,2 @@
<?php
echo "用户端:".$_SERVER['REMOTE_ADDR'].":".$_SERVER['REMOTE_PORT']."<br>".$_SERVER['REMOTE_HOST'];

10
3.work3.php Normal file
View File

@ -0,0 +1,10 @@
<?php
echo "hello world";
print "hello world";
printf("%s", "hello world");
print_r("hello world");
$arr1 = array('a'=>1, 'b'=>2, 'c'=>3);
print_r($arr1);
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
print_r ($a);

9
4.test1.php Normal file
View File

@ -0,0 +1,9 @@
<?php
$month = date("n");
$today = date("j");
$boo = false;
if ($boo == false) //如果$boo == false即表达式为真成立
echo "true";
else
echo "false"; ?>

12
4.work1.php Normal file
View File

@ -0,0 +1,12 @@
<?php
$arr2 = array(
array(1,2,3),
array(4,5,6),
array(7,8,9)
);
foreach ($arr2 as $sub_array) {
foreach ($sub_array as $item){
echo $item.' ';
}
echo "<p>";
}

26
4.work2.php Normal file
View File

@ -0,0 +1,26 @@
<?php
/*
* 输出杨辉三角居中效果直接用html
*/
echo '<p style="text-align: center">';
$n = 10;
$data = array();
for ($k = 0; $k < $n; $k++) {
$data[$k] = array();
}
for ($i = 0; $i < $n; $i++) {
for ($j = 0; $j <= $i; $j++) {
if ($i == $j || $j == 0) {
$data[$i][$j] = 1;
continue;
}
$data[$i][$j] = $data[$i - 1][$j] + $data[$i - 1][$j - 1];
}
}
foreach ($data as $sub_data) {
foreach ($sub_data as $item) {
echo $item.' ';
}
echo '<br>';
}
echo '</p>';

4
4.work3.php Normal file
View File

@ -0,0 +1,4 @@
<?php
foreach ($_REQUEST as $param => $value){
echo "$param:$value"."<br>";
}

9
5.test1.php Normal file
View File

@ -0,0 +1,9 @@
<?php
$sql = "select * from tb_book where bookname = 'PHP从入门到精通'";
echo $sql.'<br>';
$a_sql = addslashes($sql);
$s_a_sql = stripcslashes($a_sql);
echo $a_sql.'<br>';
echo $s_a_sql.'<br>';

11
5.test2.php Normal file
View File

@ -0,0 +1,11 @@
<html>
<head>
<title>密码强度检测</title>
</head>
<body>
<form action="5.test2_pwdck.php" method="post">
<label for="user">用户名:</label><input type="text" name="username" id="user">
<label for="pwd">密码:</label><input type="password" name="password" id="pwd">
<input type="submit" value="提交">
</form>
</body>

5
5.test2_pwdck.php Normal file
View File

@ -0,0 +1,5 @@
<?php
if (strlen($_POST['password']) < 6)
echo '<script>alert("用户密码长度不得少于6位");history.back();</script>';
else
echo "用户信息输入合法";

10
5.test3.php Normal file
View File

@ -0,0 +1,10 @@
<?php
$str= "hello world!!";
$replace_content = "??";
echo substr_replace($str,$replace_content,11,2);
$number = 1868.96;
echo number_format($number)."<br>";
echo number_format($number,2)."<br>";
$number1 = 11886655.760055;
echo number_format($number1,2,'.','.');

3
5.work1.php Normal file
View File

@ -0,0 +1,3 @@
<?php
$str = '&& 明日编程词典 &&';
echo trim($str,'&');

13
5.work2.idv.php Normal file
View File

@ -0,0 +1,13 @@
<?php
$id_number = trim($_POST['id_number']);
if(strlen($id_number)!=18){
echo <<<eol
<script>
alert("提交的身份证号长度不正确,请重新提交");
history.back();
</script>
eol;
}
else{
echo "提交的身份证号长度正确";
}

13
5.work2.php Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>身份证长度检测</title>
</head>
<body>
<form action="5.work2.idv.php" method="post">
<label for="id_number1">身份证号:</label>
<input type="text" name="id_number" id="id_number1" required>
<input type="submit" value="submit">
</form>
</body>

5
5.work3.markup.php Normal file
View File

@ -0,0 +1,5 @@
<?php
$text = nl2br($_POST['text']);
$keyword = trim($_POST['keyword']);
$text1 = str_ireplace($keyword,"<span style='color: red'><b>$keyword</b></span>",$text);
echo $text1;

15
5.work3.php Normal file
View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>关键字标记测试</title>
</head>
<body>
<form action="5.work3.markup.php" method="post">
<label for="text1">文章内容:</label>
<textarea name="text" id="text1"></textarea>
<label for="keyword1">关键字:</label>
<input type="text" name="keyword" id="keyword1" required>
<input type="submit" value="查询">
</form>
</body>

23
5.work4.php Normal file
View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>全国省会城市</title>
</head>
<body>
<form>
<label for="city_selector1">省会城市选择:</label>
<select name="city" id="city_selector1">
<?php
$p_city = "北京,天津,上海,重庆,沈阳,长春,哈尔滨,南京,杭州,合肥,福州,南昌,济南,郑州,武汉,长沙,广州,南宁,海口,成都,贵阳,昆明,西安,兰州,西宁,银川,乌鲁木齐,台北,香港,澳门";
$city = explode(',',$p_city);
foreach ($city as $item){
echo "<option value='$item'>$item</option>";
}
?>
</select>
</form>
</body>

45
6.work1.php Normal file
View File

@ -0,0 +1,45 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>UBB应用</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
body {
margin-left: 10px;
margin-top: 10px;
margin-right: 10px;
margin-bottom: 10px;
}
-->
</style>
</head>
<body>
<?php
$url = '[url=http://www.mrbccd.com/]编程词典网[/url]';
$color = '[color=red]蓝色[/color]';
$b = '[b]粗体[/b]';
$string = '超链接:'.$url;
$string .= '<br>字体颜色:'.$color;
$string .= '<br>粗体:'.$b;
$rst = '超链接: '.preg_replace('/\[url=(http:\/\/\w+(\.\w+)+\/.*)\](.*)\[\/url\]/is','<a href="$1">$3</a>',$url);
$rst .= '<br>字体颜色: '.preg_replace('/\[color=(.*)\](.*)\[\/color\]/','<span style="color: $1">$2</span>',$color);
$rst .= '<br>粗体: '.preg_replace('/\[b\](.*)\[\/b\]/','<b>$1</b>',$b);
?>
<table border="1" cellpadding="0" cellspacing="0" bgcolor="f0f0f0">
<tr>
<td align="center"><h3>UBB使用帮助</h3></td>
<td align="center"><h4>实例效果</h4></td>
</tr>
<tr>
<td><?php echo $string; ?></td>
<td><?php echo $rst; ?></td>
</tr>
</table>
</body>
</html>

26
6.work2.php Normal file
View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>关键字标记测试</title>
</head>
<body>
<form>
<label for="email1">电子邮箱地址:</label>
<input type="text" name="email" id="email1" required onblur="checkEmailFormat()">
</form>
<script>
function checkEmailFormat(){
var mail = document.getElementById('email1').value.trim();
if(mail.length===0){
return;
}
var regex = /^\S+@([a-zA-Z0-9\-])+(\.[a-zA-Z0-9-]+)+$/;
if(regex.test(mail)){
alert('匹配');
}else {
alert('不匹配');
}
}
</script>
</body>

34
6.work3.php Normal file
View File

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>html标签匹配</title>
</head>
<body>
<form method="post" action="#">
<label for="html_code1">在这里输入html代码:</label>
<input type="text" name="html_code" id="html_code1" required/>
<input type="submit" value="提交">
</form>
<?php
$code = $_POST['html_code'] ?? '';
if (trim($code) != '') {
$regex = '/^<[\/]?[a-zA-z0-9 ="\';":]*>/';
// 貌似只匹配标签的部分
$preg_match = preg_match($regex, $code);
switch ($preg_match) {
case 1:
$code = str_replace('<', '&lt', $code);
$code = str_replace('>', '&gt', $code);
$code = str_replace('"', '&quot', $code);
echo $code;
break;
case 0:
echo '未找到html标签';
break;
default:
echo 'ERROR';
}
}
?>
</body>

7
7.test1.php Normal file
View File

@ -0,0 +1,7 @@
<?php
$url = array('编程词典网' => 'www.mrbccd.com',
'编程体验网' => 'www.bcty365.com',
'编程资源网' => 'www.bc110.com',);
foreach ($url as $link) {
echo $link . '<br>';
}

28
7.test2.php Normal file
View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录</title>
</head>
<body>
<form method="post" action="#" name="form1">
<table>
<tr>
<td><label for="username1">用户名</label></td>
<td><input type="text" name="username" id="username1"></td>
</tr>
<tr>
<td><label for="password1">密码</label></td>
<td><input type="password" name="password" id="password1"></td>
</tr>
<tr>
<td colspan="2" style="text-align: center"><input type="submit" value="提交"></td>
</tr>
</table>
</form>
<?php
foreach ($_POST as $item => $value){
echo "$item:$value".'<br>';
}
?>
</body>

28
7.test3.ok.php Normal file
View File

@ -0,0 +1,28 @@
<?php
/*
* 支持上传多个文件
* 如果你遇到了上传失败的问题
* 请检查PHP的post_max_size、upload_max_filesize属性值
*/
if (!is_dir("./upload")) {
mkdir("./upload");
}
print_r($_FILES);
echo '<br>';
$file_array = array_unique($_FILES["file"]["name"]);
print_r($file_array);
$result = true;
foreach ($file_array as $key => $value) {
if($value){
$path = "upload/".$value;
if(!move_uploaded_file($_FILES["file"]["tmp_name"][$key],$path)){
$result = false;
}
}
}
if($result){
echo "文件上传成功";
}else{
echo "文件上传失败";
}
echo '<meta http-equiv="refresh" content="3; url = 7.test3.php">';

44
7.test3.php Normal file
View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>文件上传</title>
</head>
<body>
<form method="post" action="7.test3.ok.php" enctype="multipart/form-data">
<table>
<tr>
<td>
<label for="file1">待上传的文件1:</label>
</td>
<td>
<input type="file" name="file[]" id="file1">
</td>
</tr>
<tr>
<td>
<label for="file2">待上传的文件2:</label>
</td>
<td>
<input type="file" name="file[]" id="file2">
</td>
</tr>
<tr>
<td>
<label for="file3">待上传的文件3:</label>
</td>
<td>
<input type="file" name="file[]" id="file3">
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<input type="submit" value="提交">
</td>
</tr>
</table>
</form>
<?php
?>
</body>

BIN
images/dx.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB