Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Kommentare (HTML soll deaktiviert sein)

Empfohlene Antworten

Veröffentlicht

Hallo! Ich habe ein paar Fragen, da ich ein Newssystem entwicklen möchte, wobei die User zu jeder News auch Kommentare posten können.

Infos:

Ich hab n' Formular mit entsprechendem Textfeld (normales <textarea>), dessen Inhalt in meine mysql-db gespeichert wird.

Also hier ma meine Fragen:

1.) Wenn ich den kommentar auslese, dann sollen die Zeilenumbrüche (/n wird zu <br> umgewandelt) angezeigt werden, aber alle anderen HTML-Tags sollen NICHT angezeigt werden (HTML-Code soll also NICHT möglich/erlaubt sein)

Kann mir da jemand helfen?

Die Zeilenumbrüche bkeommst du mit nl2br() (New Line to BR), also z.B.

$Variable=nl2br($Variable)

Zum html-Deaktivieren sollte es die Zeile tun (aus dem phpBB2 entnommen):

$message = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $message);

Das ersetzt die Tag-Zeichen mit dem dazugehörigen HTML-Code, so das die HTML-Zeichen nicht "ausgeführt", sondern nur dargestellt werden

PHP bietet auch noch die Funktion strip_tags(), die alle HTML-Tags rauswirft.

Kleiner Hinweis noch:

Ich würd das strip_tags vor das nl2br setzen. ;)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.