Home >Backend Development >PHP Tutorial > 关于PHP中函数的返回值的有关问题

关于PHP中函数的返回值的有关问题

WBOY
WBOYOriginal
2016-06-13 13:30:18787browse

关于PHP中函数的返回值的问题

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->function Traverse_files($dir1,$dir2){
  $dir = $dir1.'/'.$dir2;
  //print $dir;
  //exit;
  $ss = array();
  if (is_dir($dir)){
    if ($dh = opendir($dir)){
      while (($file = readdir($dh)) !== false){
        if($file!=="."&& $file!==".."){
          $ss[]=$file;
        }
      }
      print_r($ss);
      return $ss;
      closedir($dh);
    }
  }
}
$dirbase = 'd:';
$dirito = '5-24';
$bb = Traverse_files($dirbase,$dirito);
printf($bb);





上代码,问题是上面retrun的值出不来。。$ss在上面可以打印出来。
如何解决。。

------解决方案--------------------
printf() 函数输出格式化的字符串。 应该用 print_r($bb);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn