php笔试题 <?php$a=system('dir /b');foreach($a as $b){$c=substr("$b", -3); if($c=="jpg"){ echo $b; }}?> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 win下<?php $a=system('dir /b'); foreach($a as $b){ $c=substr("$b", -3); if($c=="jpg"){ echo $b; } } ?>linux下<?php $a=system('ls'); foreach($a as $b){ $c=substr("$b", -3); if($c=="jpg"){ echo $b; } } ?>如果有中文就用substring代替substr。但是注意,要在配置文件里打开substring支持。 <?php$dh = opendir('.');// 打开目录if(false === $dh) { echo 'opendir failed!'; exit;}while(false !== ($file = readdir($dh))){// 读取 if(!is_file($file)) continue; if(function_exists('exif_imagetype')) {// 精确判断1,需要exif扩展 if(IMAGETYPE_JPEG == exif_imagetype($file)) echo $file."<br />\n"; }elseif(function_exists('getimagesize')) {// 精确判断2 $imageinfo = getimagesize($file); if(false === $imageinfo) continue; if(IMAGETYPE_JPEG == $imageinfo[2]) echo $file."<br />\n"; }else {// 不精确判断,根据扩展名 if('.jpg' == substr($file, -4) || '.jpeg' == substr($file, -5)) echo $file."<br />\n"; }}closedir($dh);?> <?phpforeach(glob("*.jpg") as $filename){ echo $filename."<br>";}?> 关于工厂模式的问题 table内循环(smarty) php对象 php简单问题 下拉表单联动的问题 如何循环插入 新手请教一个简单问题:在PHP中如何实现VALIDATA(验证)的功能? 关于zend 如何在php的代码段中打开数据库 php怎么输出以下使用聚集函数和分组数据查询出来的MySQL查询结果? php搜索的问题.有时候能搜索出来有时候不行. 关于php的后台安全登陆问题
<?php
$a=system('dir /b');
foreach($a as $b){
$c=substr("$b", -3);
if($c=="jpg"){
echo $b;
}
}
?>linux下
<?php
$a=system('ls');
foreach($a as $b){
$c=substr("$b", -3);
if($c=="jpg"){
echo $b;
}
}
?>如果有中文就用substring代替substr。但是注意,要在配置文件里打开substring支持。
$dh = opendir('.');// 打开目录
if(false === $dh) {
echo 'opendir failed!';
exit;
}while(false !== ($file = readdir($dh))){// 读取
if(!is_file($file))
continue;
if(function_exists('exif_imagetype')) {// 精确判断1,需要exif扩展
if(IMAGETYPE_JPEG == exif_imagetype($file))
echo $file."<br />\n";
}elseif(function_exists('getimagesize')) {// 精确判断2
$imageinfo = getimagesize($file);
if(false === $imageinfo)
continue; if(IMAGETYPE_JPEG == $imageinfo[2])
echo $file."<br />\n";
}else {// 不精确判断,根据扩展名
if('.jpg' == substr($file, -4) || '.jpeg' == substr($file, -5))
echo $file."<br />\n";
}
}closedir($dh);
?>
foreach(glob("*.jpg") as $filename)
{
echo $filename."<br>";
}
?>