1
votes

I am getting an error during my execution of the code:

PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\apache2triad\htdocs\imagedisplay.php on line 28

<?php

$dir= "C:\apache2triad\htdocs\phppgadmin\images\phpimages";

$file_display= array('jpg', 'jpeg', 'png', 'gif');

if(file_exists($dir)== false) 
{
  echo "directory x not found";
}
else
{
  $dir_content= scandir($dir);

  foreach($dir_content as $file)
  {
    $file_type = strtolower(end(explode('.', $file)));
     
    // echo "$file <br> ";

    if($file !=='.' && $file !=='..')
    {
      //echo "$file <br> ";   
      echo "<img src="', $dir, '/', $file, '" alt="', $file, '"/>";
    }      
  }   
}
?>
1
Where is line 28 here? Also a dot (.) is used to concatenate strings in PHP, not a comma... - Lix
@lix: echo accepts multiple comma-separated arguments - Marc B
please indent and format your code properly next time. - Femaref
@marc - Did not know that! Good info - thanks! - Lix
As usual, an editor or IDE with syntax highlighting would help. - mario

1 Answers

3
votes
echo "<img src="', $dir, '/', $file, '" alt="', $file, '"/>";
               ^^-- here

You've essentially got two different strings back-to-back here, making this line completely invalid.