Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Problem z komendą echo, kolejne echa kontynuują tekst w tej samej linii
Rafal Z
post
Post #1





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 12.05.2007

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


Witam,

Udało mi się właśnie zainstalować Apache2.0.59 i PHP 5.2 na moim komputerze. PHP wydaje się, że działa ale kiedy startuję dokument o poniżej podanej treści:

  1. <?php
  2. Echo "string1";
  3. Echo "string2";
  4. ?>


jako wynik Firefox i IE6.0 wyświetlają co następuje string1string2.
Z dokumentacji PHP wynika, że Komenda "Echo "string2"" powinna wypisać teskst w nowej linijce. Przykłady wzięte z tutorialu też raczej nieprawidłowo są wyświetlane.

Następująca modyfikacja nie zmieniła formatu wyświetlania:

  1. <?php
  2. Echo "string1n";
  3. Echo "string2";
  4. ?>


Jak sobie z tym poradzić

Rafal Z
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Rafal Z
post
Post #2





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 12.05.2007

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


W takim razie jak rozumieć następujący wpis w dokumentacji
Cytat
If the string is enclosed in double-quotes ("), PHP understands more escape sequences for special characters:

Table 11.1. Escaped characters
sequence meaning
\n linefeed (LF or 0x0A (10) in ASCII)
\r carriage return (CR or 0x0D (13) in ASCII)
\t horizontal tab (HT or 0x09 (9) in ASCII)
\\ backslash
\$ dollar sign
\" double-quote
\[0-7]{1,3} the sequence of characters matching the regular expression is a character in octal notation
\x[0-9A-Fa-f]{1,2} the sequence of characters matching the regular expression is a character in hexadecimal notation

Again, if you try to escape any other character, the backslash will be printed too! Before PHP 5.1.1, backslash in \{$var} hasn't been printed.

But the most important feature of double-quoted strings is the fact that variable names will be expanded. See string parsing for details.
cytat: PHP Manual->Types->Strings
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: 5.10.2025 - 11:44