Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> readdir(), odrazu mowie zem noob
Kreton
post
Post #1





Grupa: Zarejestrowani
Postów: 345
Pomógł: 3
Dołączył: 20.02.2005

Ostrzeżenie: (0%)
-----


Kod
<?php
$dh = opendir ("/Galeria/");
while ($file = readdir ($dh)) {
print "$file\n";
}
closedir ($dh);
?>


skrypt czyta wszytkie pliki w katalogu,
jestem dopiero pocztkowym programista wiec pomozcie:
wyskakuje bład

Kod
Parse error: parse error, unexpected $ in /home3/gi/gim3e/readdir.php on line 7


HELP

Ten post edytował Kreton 14.03.2005, 17:16:27
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
tiraeth
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 1 789
Pomógł: 41
Dołączył: 30.10.2003
Skąd: Wrocław

Ostrzeżenie: (0%)
-----


\n to znak nowej linii ale nie html'owski.... zamiast \n daj <br />

  1. <?php
  2. if($dh = opendir (&#092;"Galeria\"))
  3. {
  4.  while( ($file = readdir($dh)) !== false )
  5.  {
  6. if($file !== '.' && $file !== '..')
  7. {
  8.  if(is_dir($file))
  9.  {
  10. echo '[d] ';
  11.  }
  12.  echo $file.&#092;"<br />\";
  13. }
  14.  }
  15. }
  16. closedir ($dh);
  17. ?>


Teraz wyświetli [d] jeżeli napotka katalog...
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 6.10.2025 - 22:48