im getting this error:
Parse error: syntax error, unexpected T_ECHO in /home/labvc/public_html/AT/si开发者_JAVA技巧te/getimages.php on line 26
from this code:
<?php
echo '<br />';
echo '<div id=gallery>';
function getDirTree($dir,$p=true) {
$d = dir($dir);$x=array();
while (false !== ($r = $d->read())) {
if($r!="."&&$r!=".."&&(($p==false&&is_dir($dir.$r))||$p==true)) {
$x[$r] = (is_dir($dir.$r)?array():(is_file($dir.$r)?true:false));
}
}
foreach ($x as $key => $value) {
if (is_dir($dir.$key."/")) {
$x[$key] = getDirTree($dir.$key."/",$p);
}
}
ksort($x);
return $x;
}
$tree = getDirTree("./res/gallery/painting/");
foreach($tree as $element => $eval) {
if (is_array($eval)) {
foreach($eval as $file => $value) {
if (strstr($file, "png")||strstr($file, "jpg")||strstr($file, "bmp")||strstr($file, "gif")) {
$item = $tree.'/'.$element.$file;
$itemthumb = $tree.'/thumbs/'.$element.$file;
echo '<a href="'.$item.'"><img src="'.$itemthumb.'" alt="'.$file.'"/></a>';
}
}
}
}
echo '</div>';
echo '<br />';
echo 'tree: '.$tree.'<br />';
echo 'element: '.$element.'<br />';
echo 'file: '.$file.'<br />';
$abc="res/gallery/painting";
$def="01.png";
echo'<a href="'.$abc.$def.'"><img src="'.$abc.'/thumbs/'.$def.'" alt="'.$def.'"/></a>';
echo '<br />';
line 26 is not an echo, theres not even an echo close to line 26
foreach($tree as $element => $eval) {
Any ideas?
I know it sounds silly, but are you actually looking at / editing the file you are debugging?
Any number of times it turned out I was in directory A/foo.c, when the code was being run out of directory B/foo.c. I always feel stooooopid after doing this.
Stick a print "foo!"
in there to see if you are actually in the file you think you are.
This seems a suspicious line:
$item = $tree.'/'.$element.$file;
$tree
should be an array, so if you get the error at runtime (as opposed to compile time) then it would make sense it would complain about this.
精彩评论