Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem ze znakiem chr(92)
inf16
post 10.09.2014, 21:15:00
Post #1





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

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


Witam
wie ktoś może jak zamienić znak \ na \n ? bo mi w żaden sposób nie wychodzi i tylko błedy wywala jak próbuje za pomoc str_replace zamieniać sad.gif
syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
myślałem że jak skorzystam z chr(92) to mi przejdzie to wyrzuciło
unexpected T_STRING

Dzięki z góry za pomoc
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 10)
Pyton_000
post 10.09.2014, 21:19:04
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Str_replace("\\", '\n');
Go to the top of the page
+Quote Post
inf16
post 10.09.2014, 21:27:29
Post #3





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

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


  1. $proba=str_replace('<br />','',$tmp);
  2. $proba2=str_replace("\\","\n",$proba)

i dalej wywala błąd:
syntax error, unexpected T_STRING
nio chyba że ja coś poplątałem z zamianą znaków
Go to the top of the page
+Quote Post
Pyton_000
post 10.09.2014, 21:35:46
Post #4





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


A możesz powiedzieć co ty chcesz osiągnąć?
Go to the top of the page
+Quote Post
inf16
post 10.09.2014, 21:43:46
Post #5





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

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


pisze sobie prosty edytor
  1. <form action="editor.php?create=save" method="post">
  2. <table border="0" bordercolor="black" cellspacing="0" cellpadding="0" width="708" style="margin-left:40px; margin-top:20px;">
  3. <tr><td width="221" height="53" valign="top" class="newfile">
  4. <input type="text" name="plik" class="pole2">
  5. </td><td width="113" height="53" valign="top">
  6. <input type="submit" class="newfile1" value=" " title="kliknij by zapisac" hidefocus=true style="outline:none">
  7. </td><td width="371" height="53" valign="top" class="newfile2"><a href="editor.php?oki=zarzadzaj" class="linki" style="margin-left:340px;" hidefocus=true style="outline:none"></a></td></tr></table>
  8. <table border="0" bordercolor="black" cellspacing="0" cellpadding="0" width="708" style="margin-left:40px;">
  9. <tr><td width="708" height="184" valign="top" class="newfile3">
  10. <textarea name="tekst" style="margin-left:15px; width:677px; height:335px; background-color:#e5e4e4; border: 1px solid #6e6666;">
  11. </td></tr></table>
  12. <table border="0" bordercolor="black" cellspacing="0" cellpadding="0" width="708" style="margin-left:40px;">
  13. <tr><td width="708" height="22" valign="top" class="newfile4"></td></tr></table>
  14. </form>

  1. if($_GET['create']==save){
  2. $csfile=$_POST['plik'];
  3. $text=$_POST['tekst'];
  4. $plik=fopen($csfile,"w+");
  5. $plik2=fopen("tmp.txt","w");
  6. $tmp=nl2br($text);
  7. $proba=str_replace('<br />','',$tmp);
  8. fputs($plik,$proba);
  9. fputs($plik2,$csfile);
  10. echo'<meta http-equiv="refresh" content="0; url=editor.php?conti=nued">';
  11. }

i podczas wczytywanie z pliku *.php którego tworze za pomocą skryptu
  1. <title>proba</title>
  2. </head>
  3. <?
  4. echo\"aaa\"; # i tych dwóch znaczników \\ chce się pozbyć
  5. ?>
  6. </body>
  7. </html>


Ten post edytował inf16 10.09.2014, 21:59:28
Go to the top of the page
+Quote Post
kreatiff
post 11.09.2014, 01:02:21
Post #6





Grupa: Zarejestrowani
Postów: 324
Pomógł: 105
Dołączył: 7.08.2012

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


stripslashes ?
Chociaż nie do końca wiem o co chodzi, to ta funkcja służy właśnie to usuwania tych "dodatkowych" slashy.

Ten post edytował kreatiff 11.09.2014, 01:04:24
Go to the top of the page
+Quote Post
inf16
post 11.09.2014, 06:16:50
Post #7





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

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


Dzięki poszło działa moge tworzyć pliki PHP specool.gif
Go to the top of the page
+Quote Post
nospor
post 11.09.2014, 06:52:43
Post #8





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Innym rozwiązaniem, o wiele bardziej prawidlowym, jest wyłączenie opcji MAGIC_QUOTES. Lecisz na jakiś archaicznych ustawieniach php....

ps:
Najpierw zamieniasz nowe linie na br
$tmp=nl2br($text);

a potem kasujesz te br
$proba=str_replace('<br />','',$tmp);

Po grzyba? Poprostu wywal te dwie linijki
$tmp=nl2br($text);
$proba=str_replace('<br />','',$tmp);
i nie cuduj bez sensu.


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
inf16
post 11.09.2014, 07:23:34
Post #9





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

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


pewnie i rozwiązanie głupie ale działa tak jak chciałem i to się LICZY yahoo.gif
Go to the top of the page
+Quote Post
nospor
post 11.09.2014, 07:24:56
Post #10





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Zajebiste podejscie do sprawy. Zycze wiec dalszych sukcesow na drodze programowania.


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
inf16
post 11.09.2014, 07:27:06
Post #11





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

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


dziękuje aaevil.gif
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 24.06.2025 - 00:28