a

---恢复内容开始---

1输出本周一的时间        echo date('Y-m-d' ,strtotime('-1 day'));

2遍历某文件价下所有文件名并输出

<?php
function traverse($path = '.') {
$current_dir = opendir($path); //opendir()返回一个目录句柄,失败返回false
while(($file = readdir($current_dir)) !== false) { //readdir()返回打开目录句柄中的一个条目
$sub_dir = $path . DIRECTORY_SEPARATOR . $file; //构建子目录路径
if($file == '.' || $file == '..') {
continue;
} else if(is_dir($sub_dir)) { //如果是目录,进行递归
echo 'Directory ' . $file . ':<br>';
traverse($sub_dir);
} else { //如果是文件,直接输出
echo 'File in Directory ' . $path . ': ' . $file . '<br>';
}
}
}

traverse('E:/');
?>

3获取字符串中某个字符出现的次数和出现的位置

$a = array('2','3','4','2','3','5');

$b= count_array_value($a);//出现次数

$c= $b['2'];

$d = strpos($a,2);//查找出现的位置

4nl2br()与一个html***的区别

nl2br() 函数在字符串中的每个新行 ( ) 之前插入 HTML 换行符 (<br />)。

echo nl2br("One line. Another line.")

输出:

One line. Another line.

HTML 代码:
  

One line.<br /> Another line.

5如何防止sql注入

加转义字符串

addslashes();

原文地址:https://www.cnblogs.com/legendyang/p/3622787.html