Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [HTML][PHP]Prosty problem z "/" oraz wstawieniem opisu ALT
bardakon
post
Post #1





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 1.06.2010

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


Mam skrypt losowanie zdjęć z folderu images

  1. <?php
  2. $obrazki = array("2.jpg", "3.jpg", "4.jpg", "5.jpg");
  3.  
  4. srand ((float) microtime() * 10000000);
  5.  
  6. $obrazek = $obrazki[array_rand($obrazki)];
  7.  
  8. echo "<img src=images/$obrazek alt=\"zdjecie losowe;\" style=\"width: 260px; height: 200px;\">";
  9. ?>


Niestety nie potrafię dodać sensownie parametru ALT (może być taki sam dla wszyskich zdjęć), a drugim problemem jest błąd którego zupełnie nie rozumiem związany ze znakiem / we frazie: "images/$obrazek".

Kopiuję co podaje http://validator.w3.org:

Cytat
1. Warning Line 70, Column 18: NET-enabling start-tag requires SHORTTAG YES

<img src=images/4.jpg alt="zdjecie losowe;" style="width: 260px; height: 200p?

?

The sequence <FOO /> can be interpreted in at least two different ways, depending on the DOCTYPE of the document. For HTML 4.01 Strict, the '/' terminates the tag <FOO (with an implied '>'). However, since many browsers don't interpret it this way, even in the presence of an HTML 4.01 Strict DOCTYPE, it is best to avoid it completely in pure HTML documents and reserve its use solely for those written in XHTML.
2. Error Line 70, Column 18: required attribute "ALT" not specified

<img src=images/4.jpg alt="zdjecie losowe;" style="width: 260px; height: 200p?

?

The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.

Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.


Dziękuję za pomoc w usunięciu ostatnich błędów w kodzie.

Ten post edytował bardakon 1.06.2010, 14:10:20
Go to the top of the page
+Quote Post
tehaha
post
Post #2





Grupa: Zarejestrowani
Postów: 1 748
Pomógł: 388
Dołączył: 21.08.2009
Skąd: Gdynia

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


  1. echo "<img src=\"images/$obrazek\" alt=\"zdjecie losowe;\" style=\"width: 260px; height: 200px;\" />";
Go to the top of the page
+Quote Post

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: 23.08.2025 - 23:31