复制
收藏
提问
全网

<?php $filename = dirname(__FILE__).'./new_shuju.txt'; if(file_exists($filename)&&filesize($filename)>0){ // $str = file_get_contents($filename); // $dudu = unserialize($str); include_once($filename); $dudu = $arr; }else exit('数据文本不存在!'); // 点赞处理 if(isset($_POST['like']) && isset($_POST['index'])) { $index = $_POST['index']; $dudu[$index]['like']++; // 将更新后的数据写回文件 $dataToWrite = "<?php\n\$arr = ". var_export($dudu, true). ";\n?>"; file_put_contents($filename, $dataToWrite); } // 处理评论存储 if(isset($_POST['comment']) && isset($_POST['dataIndex'])) { $comment = $_POST['comment']; $dataIndex = $_POST['dataIndex']; if(isset($dudu[$dataIndex])) { if(!isset($dudu[$dataIndex]['comments'])) { $dudu[$dataIndex]['comments'] = []; } $dudu[$dataIndex]['comments'][] = $comment; $dataToWrite = "<?php\n\$arr = ". var_export($dudu, true). ";\n?>"; file_put_contents($filename, $dataToWrite); } } foreach ($dudu as $kk=>&$vv){} $sort = array_column($dudu,'sort'); if($sort) array_multisort($sort,SORT_DESC,$dudu); $pagecount=is_array($dudu)?count($dudu):0;//计算总数 $setpage=15;//设置页面显示数量 $page=isset($_GET['page'])? $_GET['page'] : 1; $total=ceil($pagecount/$setpage); $newarr = array_slice($dudu, ($page-1)*$setpage, $setpage); //print_r($newarr);print_r($pagecount); //pr(check_url("YY ")); if(isset($_REQUEST['_ajax'])){ echo check_url($_REQUEST['url']); exit; } ?><form name="example" action="./fabuc.php" method="post"> <input type="hidden" name="act" value="add"/><textarea oninput="filterSensitiveWords(event)" id="Textarea" cols="50" rows="25" maxlength="500" class= "textArea" name="zhu" maxNumber="10000" style="height:300px;display: inline-block;line-height: 1.5;border-style: ridge;border: 1px solid RGB(96,93,92);float:left;" placeholder="内容500文字以内<支持HTML代码>" ></textarea> <div><input type="submit" style="font-size:15px;" value="发布"/></div> </form><?php for($kay=0;$kay<count($newarr);$kay++){ $val=$newarr[$kay]; ?> <table style="width:100%;border-style: solid;border-radius: 20px 20px 20px 20px;word-break:break-all;padding:0 230 0 400;" border="0"> <tr> <td style="font-size:16px;"> <span style="text-decoration: underline;margin-left: 10px; font-size:16px;cursor: pointer;" onclick="showPopup(<?php echo $kay;?>)"><?php echo $val['zhu2'];?></span> <span style="margin-left: 5px;font-size:11px;"><button onclick="showCommentPopup(<?php echo $kay;?>)">评论<?php echo count($val['comments']);?></button></span> </td> <td style="border-color: #6495ED;background-color:RGB(132,194,37);text-align:right;height:40px;"> <span id="<?php echo $kay?>" style="font-size:13px;" autoplay="false"></span>&nbsp; </td> </tr> </table> <hr style="border: 1px dashed #d9d6c3;"> <?php }?> <script> function showPopup(index) { document.getElementById('popup' + index).style.display = "block"; } function hidePopup(index) { document.getElementById('popup' + index).style.display = "none"; } function showCommentPopup(index) { document.getElementById('commentPopup' + index).style.display = "block"; } function hideCommentPopup(index) { document.getElementById('commentPopup' + index).style.display = "none"; } </script> <?php for($kay=0;$kay<count($newarr);$kay++){ $val=$newarr[$kay]; ?> <div id="popup<?php echo $kay;?>" class="popup"> <div class="popup-content"> <?php echo $val['zhu'];?> <a class="close" style="font-size:60px;color: #fff;" onclick="hidePopup(<?php echo $kay;?>);">×</a> </div> </div> <div id="commentPopup<?php echo $kay;?>" class="popup"> <div class="popup-content"> <form method="post" action=""> <input type="text" name="comment" placeholder="添加评论"> <input type="hidden" name="dataIndex" value="<?php echo $kay;?>"> <input type="submit" value="提交评论"> </form> <div> <?php if(isset($val['comments'])) {?> <span style="margin-left: 10px;">评论:<?php foreach($val['comments'] as $comment) { echo $comment. ', '; }?></span> <?php }?> </div> <a class="close" style="font-size:60px;color: #fff;" onclick="hideCommentPopup(<?php echo $kay;?>);">×</a> </div> </div> <?php }?> <?php session_start(); $usename = $_POST['usename']; $passname = $_POST['pass']; $userpass = $usename. "#". $passname. "#"; $myfile = fopen("username.txt", "a") or die("Unable to open file!"); fwrite($myfile, $userpass."\n"); fclose($myfile); header('Loca

机敏美学师
1个月前
全网
文档
学术
百科
知识库
时间不限
自动

理解问题<?php $filename = dirname(__FILE__).'./new_shuju.txt'; if(file_exists($filename)&&filesize($filename)>0){ // $str = file_get_contents($filename); // $dudu = unserialize($str); include_once($filename); $dudu = $arr; }else exit('数据文本不存在!'); // 点赞处理 if(isset($_POST['like']) && isset($_POST['index'])) { $index = $_POST['index']; $dudu[$index]['like']++; // 将更新后的数据写回文件 $dataToWrite = "<?php\n\$arr = ". var_export($dudu, true). ";\n?>"; file_put_contents($filename, $dataToWrite); } // 处理评论存储 if(isset($_POST['comment']) && isset($_POST['dataIndex'])) { $comment = $_POST['comment']; $dataIndex = $_POST['dataIndex']; if(isset($dudu[$dataIndex])) { if(!isset($dudu[$dataIndex]['comments'])) { $dudu[$dataIndex]['comments'] = []; } $dudu[$dataIndex]['comments'][] = $comment; $dataToWrite = "<?php\n\$arr = ". var_export($dudu, true). ";\n?>"; file_put_contents($filename, $dataToWrite); } } foreach ($dudu as $kk=>&$vv){} $sort = array_column($dudu,'sort'); if($sort) array_multisort($sort,SORT_DESC,$dudu); $pagecount=is_array($dudu)?count($dudu):0;//计算总数 $setpage=15;//设置页面显示数量 $page=isset($_GET['page'])? $_GET['page'] : 1; $total=ceil($pagecount/$setpage); $newarr = array_slice($dudu, ($page-1)*$setpage, $setpage); //print_r($newarr);print_r($pagecount); //pr(check_url("YY ")); if(isset($_REQUEST['_ajax'])){ echo check_url($_REQUEST['url']); exit; } ?><form name="example" action="./fabuc.php" method="post"> <input type="hidden" name="act" value="add"/><textarea oninput="filterSensitiveWords(event)" id="Textarea" cols="50" rows="25" maxlength="500" class= "textArea" name="zhu" maxNumber="10000" style="height:300px;display: inline-block;line-height: 1.5;border-style: ridge;border: 1px solid RGB(96,93,92);float:left;" placeholder="内容500文字以内<支持HTML代码>" ></textarea> <div><input type="submit" style="font-size:15px;" value="发布"/></div> </form><?php for($kay=0;$kay<count($newarr);$kay++){ $val=$newarr[$kay]; ?> <table style="width:100%;border-style: solid;border-radius: 20px 20px 20px 20px;word-break:break-all;padding:0 230 0 400;" border="0"> <tr> <td style="font-size:16px;"> <span style="text-decoration: underline;margin-left: 10px; font-size:16px;cursor: pointer;" onclick="showPopup(<?php echo $kay;?>)"><?php echo $val['zhu2'];?></span> <span style="margin-left: 5px;font-size:11px;"><button onclick="showCommentPopup(<?php echo $kay;?>)">评论<?php echo count($val['comments']);?></button></span> </td> <td style="border-color: #6495ED;background-color:RGB(132,194,37);text-align:right;height:40px;"> <span id="<?php echo $kay?>" style="font-size:13px;" autoplay="false"></span>&nbsp; </td> </tr> </table> <hr style="border: 1px dashed #d9d6c3;"> <?php }?> <script> function showPopup(index) { document.getElementById('popup' + index).style.display = "block"; } function hidePopup(index) { document.getElementById('popup' + index).style.display = "none"; } function showCommentPopup(index) { document.getElementById('commentPopup' + index).style.display = "block"; } function hideCommentPopup(index) { document.getElementById('commentPopup' + index).style.display = "none"; } </script> <?php for($kay=0;$kay<count($newarr);$kay++){ $val=$newarr[$kay]; ?> <div id="popup<?php echo $kay;?>" class="popup"> <div class="popup-content"> <?php echo $val['zhu'];?> <a class="close" style="font-size:60px;color: #fff;" onclick="hidePopup(<?php echo $kay;?>);">×</a> </div> </div> <div id="commentPopup<?php echo $kay;?>" class="popup"> <div class="popup-content"> <form method="post" action=""> <input type="text" name="comment" placeholder="添加评论"> <input type="hidden" name="dataIndex" value="<?php echo $kay;?>"> <input type="submit" value="提交评论"> </form> <div> <?php if(isset($val['comments'])) {?> <span style="margin-left: 10px;">评论:<?php foreach($val['comments'] as $comment) { echo $comment. ', '; }?></span> <?php }?> </div> <a class="close" style="font-size:60px;color: #fff;" onclick="hideCommentPopup(<?php echo $kay;?>);">×</a> </div> </div> <?php }?> <?php session_start(); $usename = $_POST['usename']; $passname = $_POST['pass']; $userpass = $usename. "#". $passname. "#"; $myfile = fopen("username.txt", "a") or die("Unable to open file!"); fwrite($myfile, $userpass."\n"); fclose($myfile); header('Loca

已完成理解<?php $filename = dirname(__FILE__).'./new_shuju.txt'; if(file_exists($filename)&&filesize($filename)>0){ // $str = file_get_contents($filename); // $dudu = unserialize($str); include_once($filename); $dudu = $arr; }else exit('数据文本不存在!'); // 点赞处理 if(isset($_POST['like']) && isset($_POST['index'])) { $index = $_POST['index']; $dudu[$index]['like']++; // 将更新后的数据写回文件 $dataToWrite = "<?php\n\$arr = ". var_export($dudu, true). ";\n?>"; file_put_contents($filename, $dataToWrite); } // 处理评论存储 if(isset($_POST['comment']) && isset($_POST['dataIndex'])) { $comment = $_POST['comment']; $dataIndex = $_POST['dataIndex']; if(isset($dudu[$dataIndex])) { if(!isset($dudu[$dataIndex]['comments'])) { $dudu[$dataIndex]['comments'] = []; } $dudu[$dataIndex]['comments'][] = $comment; $dataToWrite = "<?php\n\$arr = ". var_export($dudu, true). ";\n?>"; file_put_contents($filename, $dataToWrite); } } foreach ($dudu as $kk=>&$vv){} $sort = array_column($dudu,'sort'); if($sort) array_multisort($sort,SORT_DESC,$dudu); $pagecount=is_array($dudu)?count($dudu):0;//计算总数 $setpage=15;//设置页面显示数量 $page=isset($_GET['page'])? $_GET['page'] : 1; $total=ceil($pagecount/$setpage); $newarr = array_slice($dudu, ($page-1)*$setpage, $setpage); //print_r($newarr);print_r($pagecount); //pr(check_url("YY ")); if(isset($_REQUEST['_ajax'])){ echo check_url($_REQUEST['url']); exit; } ?><form name="example" action="./fabuc.php" method="post"> <input type="hidden" name="act" value="add"/><textarea oninput="filterSensitiveWords(event)" id="Textarea" cols="50" rows="25" maxlength="500" class= "textArea" name="zhu" maxNumber="10000" style="height:300px;display: inline-block;line-height: 1.5;border-style: ridge;border: 1px solid RGB(96,93,92);float:left;" placeholder="内容500文字以内<支持HTML代码>" ></textarea> <div><input type="submit" style="font-size:15px;" value="发布"/></div> </form><?php for($kay=0;$kay<count($newarr);$kay++){ $val=$newarr[$kay]; ?> <table style="width:100%;border-style: solid;border-radius: 20px 20px 20px 20px;word-break:break-all;padding:0 230 0 400;" border="0"> <tr> <td style="font-size:16px;"> <span style="text-decoration: underline;margin-left: 10px; font-size:16px;cursor: pointer;" onclick="showPopup(<?php echo $kay;?>)"><?php echo $val['zhu2'];?></span> <span style="margin-left: 5px;font-size:11px;"><button onclick="showCommentPopup(<?php echo $kay;?>)">评论<?php echo count($val['comments']);?></button></span> </td> <td style="border-color: #6495ED;background-color:RGB(132,194,37);text-align:right;height:40px;"> <span id="<?php echo $kay?>" style="font-size:13px;" autoplay="false"></span>&nbsp; </td> </tr> </table> <hr style="border: 1px dashed #d9d6c3;"> <?php }?> <script> function showPopup(index) { document.getElementById('popup' + index).style.display = "block"; } function hidePopup(index) { document.getElementById('popup' + index).style.display = "none"; } function showCommentPopup(index) { document.getElementById('commentPopup' + index).style.display = "block"; } function hideCommentPopup(index) { document.getElementById('commentPopup' + index).style.display = "none"; } </script> <?php for($kay=0;$kay<count($newarr);$kay++){ $val=$newarr[$kay]; ?> <div id="popup<?php echo $kay;?>" class="popup"> <div class="popup-content"> <?php echo $val['zhu'];?> <a class="close" style="font-size:60px;color: #fff;" onclick="hidePopup(<?php echo $kay;?>);">×</a> </div> </div> <div id="commentPopup<?php echo $kay;?>" class="popup"> <div class="popup-content"> <form method="post" action=""> <input type="text" name="comment" placeholder="添加评论"> <input type="hidden" name="dataIndex" value="<?php echo $kay;?>"> <input type="submit" value="提交评论"> </form> <div> <?php if(isset($val['comments'])) {?> <span style="margin-left: 10px;">评论:<?php foreach($val['comments'] as $comment) { echo $comment. ', '; }?></span> <?php }?> </div> <a class="close" style="font-size:60px;color: #fff;" onclick="hideCommentPopup(<?php echo $kay;?>);">×</a> </div> </div> <?php }?> <?php session_start(); $usename = $_POST['usename']; $passname = $_POST['pass']; $userpass = $usename. "#". $passname. "#"; $myfile = fopen("username.txt", "a") or die("Unable to open file!"); fwrite($myfile, $userpass."\n"); fclose($myfile); header('Loca

展开阅读网页

tion: index.php'); exit; ?>

代码分析

  1. 文件读取与验证

    • 代码首先检查文件new_shuju.txt是否存在且非空。如果存在,则包含该文件并将其内容赋值给变量$dudu。如果不存在,则输出错误信息并退出。1
  2. 点赞处理

    • 当接收到POST请求且包含likeindex参数时,代码会增加指定索引项的点赞数,并将更新后的数据写回文件。1
  3. 评论处理

    • 当接收到POST请求且包含commentdataIndex参数时,代码会将新评论添加到指定索引项的评论数组中,并将更新后的数据写回文件。1
  4. 数据排序与分页

    • 代码使用array_multisort函数对数据进行排序,并根据页面参数进行分页处理。1
  5. 表单与弹窗

    • 代码生成一个发布内容的表单,并根据数据生成展示内容的表格。每个内容项都有一个弹窗用于显示详细内容和评论。1
  6. 用户登录处理

    • 代码处理用户登录信息,将用户名和密码写入username.txt文件,并重定向到主页。1

关键函数与方法

  • file_exists:检查文件是否存在。1
  • filesize:获取文件大小。1
  • file_get_contents:读取文件内容。1
  • unserialize:将序列化字符串转换为数组。1
  • include_once:包含并运行指定文件。1
  • var_export:返回变量的字符串表示。1
  • file_put_contents:将字符串写入文件。1
  • array_column:返回数组中指定列的值。1
  • array_multisort:对多维数组进行排序。1
  • array_slice:从数组中取出一段。1
  • fopen:打开文件或URL。3
  • fwrite:写入文件。3
  • fclose:关闭打开的文件。3

总结

该PHP代码实现了文件读取、点赞和评论功能,并通过表单和弹窗展示数据。代码结构清晰,功能模块化,适合处理简单的数据存储和展示需求。123

更专业一些
转笔记
专业
<?php $filename = dirname(__FILE__).'./new_shuju.txt'; if(file_exists($filename)&&filesize($filename)>0){ // $str = file_get_contents($filename); // $dudu = unserialize($str); include_once($filename); $dudu = $arr; }else exit('数据文本不存在!'); // 点赞处理 if(isset($_POST['like']) && isset($_POST['index'])) { $index = $_POST['index']; $dudu[$index]['like']++; // 将更新后的数据写回文件 $dataToWrite = "<?php\n\$arr = ". var_export($dudu, true). ";\n?>"; file_put_contents($filename, $dataToWrite); } // 处理评论存储 if(isset($_POST['comment']) && isset($_POST['dataIndex'])) { $comment = $_POST['comment']; $dataIndex = $_POST['dataIndex']; if(isset($dudu[$dataIndex])) { if(!isset($dudu[$dataIndex]['comments'])) { $dudu[$dataIndex]['comments'] = []; } $dudu[$dataIndex]['comments'][] = $comment; $dataToWrite = "<?php\n\$arr = ". var_export($dudu, true). ";\n?>"; file_put_contents($filename, $dataToWrite); } } foreach ($dudu as $kk=>&$vv){} $sort = array_column($dudu,'sort'); if($sort) array_multisort($sort,SORT_DESC,$dudu); $pagecount=is_array($dudu)?count($dudu):0;//计算总数 $setpage=15;//设置页面显示数量 $page=isset($_GET['page'])? $_GET['page'] : 1; $total=ceil($pagecount/$setpage); $newarr = array_slice($dudu, ($page-1)*$setpage, $setpage); //print_r($newarr);print_r($pagecount); //pr(check_url("YY ")); if(isset($_REQUEST['_ajax'])){ echo check_url($_REQUEST['url']); exit; } ?><form name="example" action="./fabuc.php" method="post"> <input type="hidden" name="act" value="add"/><textarea oninput="filterSensitiveWords(event)" id="Textarea" cols="50" rows="25" maxlength="500" class= "textArea" name="zhu" maxNumber="10000" style="height:300px;display: inline-block;line-height: 1.5;border-style: ridge;border: 1px solid RGB(96,93,92);float:left;" placeholder="内容500文字以内<支持HTML代码>" ></textarea> <div><input type="submit" style="font-size:15px;" value="发布"/></div> </form><?php for($kay=0;$kay<count($newarr);$kay++){ $val=$newarr[$kay]; ?> <table style="width:100%;border-style: solid;border-radius: 20px 20px 20px 20px;word-break:break-all;padding:0 230 0 400;" border="0"> <tr> <td style="font-size:16px;"> <span style="text-decoration: underline;margin-left: 10px; font-size:16px;cursor: pointer;" onclick="showPopup(<?php echo $kay;?>)"><?php echo $val['zhu2'];?></span> <span style="margin-left: 5px;font-size:11px;"><button onclick="showCommentPopup(<?php echo $kay;?>)">评论<?php echo count($val['comments']);?></button></span> </td> <td style="border-color: #6495ED;background-color:RGB(132,194,37);text-align:right;height:40px;"> <span id="<?php echo $kay?>" style="font-size:13px;" autoplay="false"></span>&nbsp; </td> </tr> </table> <hr style="border: 1px dashed #d9d6c3;"> <?php }?> <script> function showPopup(index) { document.getElementById('popup' + index).style.display = "block"; } function hidePopup(index) { document.getElementById('popup' + index).style.display = "none"; } function showCommentPopup(index) { document.getElementById('commentPopup' + index).style.display = "block"; } function hideCommentPopup(index) { document.getElementById('commentPopup' + index).style.display = "none"; } </script> <?php for($kay=0;$kay<count($newarr);$kay++){ $val=$newarr[$kay]; ?> <div id="popup<?php echo $kay;?>" class="popup"> <div class="popup-content"> <?php echo $val['zhu'];?> <a class="close" style="font-size:60px;color: #fff;" onclick="hidePopup(<?php echo $kay;?>);">×</a> </div> </div> <div id="commentPopup<?php echo $kay;?>" class="popup"> <div class="popup-content"> <form method="post" action=""> <input type="text" name="comment" placeholder="添加评论"> <input type="hidden" name="dataIndex" value="<?php echo $kay;?>"> <input type="submit" value="提交评论"> </form> <div> <?php if(isset($val['comments'])) {?> <span style="margin-left: 10px;">评论:<?php foreach($val['comments'] as $comment) { echo $comment. ', '; }?></span> <?php }?> </div> <a class="close" style="font-size:60px;color: #fff;" onclick="hideCommentPopup(<?php echo $kay;?>);">×</a> </div> </div> <?php }?> <?php session_start(); $usename = $_POST['usename']; $passname = $_POST['pass']; $userpass = $usename. "#". $passname. "#"; $myfile = fopen("username.txt", "a") or die("Unable to open file!"); fwrite($myfile, $userpass."\n"); fclose($myfile); header('Loca
不在提醒

这个PHP脚本的主要功能是处理用户提交的数据,包括点赞、评论和发布内容。以下是该脚本的主要功能和实现方式:

文件读取与数据处理

  • 文件读取:脚本首先检查指定的文件是否存在且不为空。如果存在,则包含该文件并将其内容赋值给变量 $dudu。如果文件不存在或为空,则输出错误信息并退出脚本。
  • 数据处理:脚本通过 include_once 包含文件内容,并使用 unserialize 函数将文件内容反序列化为数组 $dudu

点赞功能

  • 点赞处理:当用户提交点赞请求时,脚本会根据提交的索引值增加相应数据的点赞数,并将更新后的数据写回文件。
  • 数据写回:使用 file_put_contents 函数将更新后的数据以PHP代码的形式写回文件。

评论功能

  • 评论处理:当用户提交评论时,脚本会根据提交的索引值将评论添加到相应数据的评论数组中,并将更新后的数据写回文件。
  • 评论存储:如果评论数组不存在,则初始化一个空数组,然后将新评论添加到数组中。

数据分页与显示

  • 数据分页:脚本通过 array_slice 函数对数据进行分页处理,根据当前页码和每页显示数量截取数据。
  • 数据显示:脚本通过循环遍历分页后的数据,生成HTML表格显示每条数据的内容、点赞数和评论数。

用户交互

  • 弹窗显示:脚本通过JavaScript函数 showPopupshowCommentPopup 实现弹窗显示内容和评论。
  • 表单提交:脚本通过HTML表单处理用户提交的内容,包括发布新内容和提交评论。

用户登录

  • 用户登录:脚本通过 session_start 函数启动会话,并处理用户登录信息,将用户名和密码写入文件 username.txt

该脚本通过文件操作和数据处理实现了基本的用户交互功能,包括点赞、评论和发布内容。通过分页和弹窗显示,提升了用户体验。

✏️展开
知识树
<?php $filename = dirname(__FILE__).'./new_shuju.txt'; if(file_exists($filename)&&filesize($filename)>0){ // $str = file_get_contents($filename); // $dudu = unserialize($str); include_once($filename); $dudu = $arr; }else exit('数据文本不存在!'); // 点赞处理 if(isset($_POST['like']) && isset($_POST['index'])) { $index = $_POST['index']; $dudu[$index]['like']++; // 将更新后的数据写回文件 $dataToWrite = "<?php\n\$arr = ". var_export($dudu, true). ";\n?>"; file_put_contents($filename, $dataToWrite); } // 处理评论存储 if(isset($_POST['comment']) && isset($_POST['dataIndex'])) { $comment = $_POST['comment']; $dataIndex = $_POST['dataIndex']; if(isset($dudu[$dataIndex])) { if(!isset($dudu[$dataIndex]['comments'])) { $dudu[$dataIndex]['comments'] = []; } $dudu[$dataIndex]['comments'][] = $comment; $dataToWrite = "<?php\n\$arr = ". var_export($dudu, true). ";\n?>"; file_put_contents($filename, $dataToWrite); } } foreach ($dudu as $kk=>&$vv){} $sort = array_column($dudu,'sort'); if($sort) array_multisort($sort,SORT_DESC,$dudu); $pagecount=is_array($dudu)?count($dudu):0;//计算总数 $setpage=15;//设置页面显示数量 $page=isset($_GET['page'])? $_GET['page'] : 1; $total=ceil($pagecount/$setpage); $newarr = array_slice($dudu, ($page-1)*$setpage, $setpage); //print_r($newarr);print_r($pagecount); //pr(check_url("YY ")); if(isset($_REQUEST['_ajax'])){ echo check_url($_REQUEST['url']); exit; } ?><form name="example" action="./fabuc.php" method="post"> <input type="hidden" name="act" value="add"/><textarea oninput="filterSensitiveWords(event)" id="Textarea" cols="50" rows="25" maxlength="500" class= "textArea" name="zhu" maxNumber="10000" style="height:300px;display: inline-block;line-height: 1.5;border-style: ridge;border: 1px solid RGB(96,93,92);float:left;" placeholder="内容500文字以内<支持HTML代码>" ></textarea> <div><input type="submit" style="font-size:15px;" value="发布"/></div> </form><?php for($kay=0;$kay<count($newarr);$kay++){ $val=$newarr[$kay]; ?> <table style="width:100%;border-style: solid;border-radius: 20px 20px 20px 20px;word-break:break-all;padding:0 230 0 400;" border="0"> <tr> <td style="font-size:16px;"> <span style="text-decoration: underline;margin-left: 10px; font-size:16px;cursor: pointer;" onclick="showPopup(<?php echo $kay;?>)"><?php echo $val['zhu2'];?></span> <span style="margin-left: 5px;font-size:11px;"><button onclick="showCommentPopup(<?php echo $kay;?>)">评论<?php echo count($val['comments']);?></button></span> </td> <td style="border-color: #6495ED;background-color:RGB(132,194,37);text-align:right;height:40px;"> <span id="<?php echo $kay?>" style="font-size:13px;" autoplay="false"></span>&nbsp; </td> </tr> </table> <hr style="border: 1px dashed #d9d6c3;"> <?php }?> <script> function showPopup(index) { document.getElementById('popup' + index).style.display = "block"; } function hidePopup(index) { document.getElementById('popup' + index).style.display = "none"; } function showCommentPopup(index) { document.getElementById('commentPopup' + index).style.display = "block"; } function hideCommentPopup(index) { document.getElementById('commentPopup' + index).style.display = "none"; } </script> <?php for($kay=0;$kay<count($newarr);$kay++){ $val=$newarr[$kay]; ?> <div id="popup<?php echo $kay;?>" class="popup"> <div class="popup-content"> <?php echo $val['zhu'];?> <a class="close" style="font-size:60px;color: #fff;" onclick="hidePopup(<?php echo $kay;?>);">×</a> </div> </div> <div id="commentPopup<?php echo $kay;?>" class="popup"> <div class="popup-content"> <form method="post" action=""> <input type="text" name="comment" placeholder="添加评论"> <input type="hidden" name="dataIndex" value="<?php echo $kay;?>"> <input type="submit" value="提交评论"> </form> <div> <?php if(isset($val['comments'])) {?> <span style="margin-left: 10px;">评论:<?php foreach($val['comments'] as $comment) { echo $comment. ', '; }?></span> <?php }?> </div> <a class="close" style="font-size:60px;color: #fff;" onclick="hideCommentPopup(<?php echo $kay;?>);">×</a> </div> </div> <?php }?> <?php session_start(); $usename = $_POST['usename']; $passname = $_POST['pass']; $userpass = $usename. "#". $passname. "#"; $myfile = fopen("username.txt", "a") or die("Unable to open file!"); fwrite($myfile, $userpass."\n"); fclose($myfile); header('Loca
如何处理文件读取错误?
文件读取的最佳实践是什么?
PHP中文件操作有哪些常见问题?

以上内容由AI搜集生成,仅供参考

在线客服