Blogger Information
Blog 30
fans 1
comment 0
visits 16057
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php中的递归函数与mysql数据库的增删查改
moon
Original
755 people have browsed it

递归函数

  • 递归函数: recursion 函数自身调用自身, 但必须调用自身之前有满足特定条件,否则会无线调用下去。以下代码展示一个删除目录文件的递归函数。
  1. function delete_dir_file($dir)
  2. {
  3. if (is_dir($dir))
  4. {
  5. $handle=opendir($dir);
  6. if ($handle)
  7. {
  8. while (($file=readdir($handle))!==false)
  9. {
  10. if ($file!="." && $file!="..")
  11. {
  12. if (is_dir($dir . DIRECTORY_SEPARATOR . $file))
  13. {
  14. delete_dir_file($dir . DIRECTORY_SEPARATOR . $file);
  15. }
  16. else
  17. {
  18. unlink($dir . DIRECTORY_SEPARATOR . $file);
  19. }
  20. }
  21. }
  22. closedir($handle);
  23. if (rmdir($dir)) {
  24. $flag = true;
  25. }
  26. }
  27. }
  28. }

mysql数据库增删查改语句

  • 增加数据insert into 表名(列1,列2,...,列n) values(值1,值2,...,值n);

  • 删除数据delete from 表名 [where 条件]

  • 查找数据select 列1,列2,...,列n from 表名 [where 条件];

  • 修改数据update 表名 set 列1=新值1,列2=新值2,...,列n=新值n [where 条件];

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post