Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: galeria
Forum PHP.pl > Forum > Gotowe rozwiązania
Arrow
widzicie cos nie prawidlowego w tym skrypcie:
[php:1:a050d17467]<?php
$katalog = opendir(cos);
$i=0;
$sciezka = "cos";
while($zdjecie = readdir($katalog))
{
if (ereg(".jpg$ |.gif$", $zdjecie))
{
$i++;
$sciezka2 = "cos/duze";
$rozmiar = file('$sciezka/$zdjecie.rozmiar');

print "<a href="java script:powieksz('cosjpg','$sciezka2/$zdjecie','$rozmiar[2]','$rozmiar[0],'$rozmiar[1]')">n";
print "<img src=$sciezka/$zdjecie border='0' alt='powiększ....'></a><br><br>n";
print "$rozmiar[2]<br><br>";
}
}
closedir($katalog);
print "Obecnie zdjęć w galeri jest: <b>$i</b>n";
?>[/php:1:a050d17467]
wszedzie dziala tylko na pewnym serwerze nie wyswietla brak zdjec, gdyby pominac sprawdzenie rozszerzen to bylo by oki ,ale sa jeszcze plik ze opiem i romziarem zdjecia
maggot
[php:1:4473f2196c]<?php
$rozmiar = file('$sciezka/$zdjecie.rozmiar');
?>[/php:1:4473f2196c]

To jest na pewno zle - pojedyncze cudzyslowy nie zamieniaja nazw zmiennych na ich wartosci (zamien je na " )
Arrow
otoz nie w tym blad to tu tylko tak mi sie wkleilo, nawet jesli to blad w tym miejscu nic nie zmienia warunek if z eregiem nie dziala, nie wiem dlaczego ten skrypt dziala na kilu serwerach bezblednie

sorkki to z przyzwyczajenia smile.gif nie wiedzialem biggrin.gif
kurtz
Cytat
widzicie cos nie prawidlowego w tym skrypcie:
[php:1:c3f9297c24]<?php
[..]
if (ereg(".jpg$ |.gif$", $zdjecie))  
[..]
?>[/php:1:c3f9297c24]

usun spacje sprzed |
po jej usunieciu warunek jest uwgledniany.


pozdrawiam
Arrow
eh dzieki ;d
spenalzo
[php:1:80f02b1df1]<?php
[..]
if (ereg(".jpg$ |.gif$", $zdjecie))
[..]
?>[/php:1:80f02b1df1]
W jakim celu stosuje się znak dolara po tekscie? I znacie jakiś dobry kurs wyrażeń?
maggot
$ oznacza, ze zmienna zdjecie musi sie konczyc na .jpg lub ( | ) na .gif


Expression Description
t Tab character.
n New line.
. Matches any character.
| Either expression on its left and right side matches the target string. For example, "a|b" matches "a" and "b".
[] Any of the enclosed characters may match the target character. For example, "[ab]" matches "a" and "b". "[0-9]" matches any digit.
[^] None of the enclosed characters may match the target character. For example, "[^ab]" matches all character EXCEPT "a" and "b". "[^0-9]" matches any non-digit character.
* Character to the left of asterisk in the expression should match 0 or more times. For example "be*" matches "b", "be" and "bee".
+ Character to the left of plus sign in the expression should match 1 or more times. For example "be+" matches "be" and "bee" but not "b".
? Character to the left of question mark in the expression should match 0 or 1 time. For example "be?" matches "b" and "be" but not "bee".
^ Expression to the right of ^ matches only when it is at the beginning of line. For example "^A" matches an "A" that is only at the beginning of line.
$ Expression to the left of $ matches only when it is at the end of line. For example "e$" matches an "e" that is only at the end of line.
() Affects evaluation order of expression and also used for tagged expression.
Escape character. If you want to use character "" itself, you should use "".

The tagged expression is enclosed by (). Tagged expressions can be referenced by , 1, 2, 3, etc. indicates a tagged expression representing the entire substring that was matched. 1 indicates the first tagged expression, 2 is the second, etc. See following examples.

Original Search Replace Result
abc (ab)© -1-2 abc-ab-c
abc a(cool.gif© -1-2 abc-b-c
abc (a)b© -1-2 abc-a-c

a tu mozesz jeszcze wiecej o tym poczytac
http://www.php.net/manual/en/pcre.pattern.syntax.php
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2024 Invision Power Services, Inc.