Community Patterns

1

gamgamtest_matei_überwiegend_version2

Created·2025-11-21 07:37
Flavor·PCRE2 (PHP)
Tier Verwalter setName($name); $this->setAlter($alter); $this->setGewicht($gewicht); $this->setGeburtsdatum($geburtsdatum); $this->setArt($art); $this->id = uniqid(); } // Getter und Setter für name public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } // Getter und Setter für alter public function setAlter($alter) { $this->alter = $alter; } public function getAlter() { return $this->alter; } // Getter und Setter für gewicht public function setGewicht($gewicht) { $this->gewicht = $gewicht; } public function getGewicht() { return $this->gewicht; } // Getter und Setter für geburtsdatum public function setGeburtsdatum($geburtsdatum) { $this->geburtsdatum = $geburtsdatum; } public function getGeburtsdatum() { return $this->geburtsdatum; } // Getter und Setter für art public function setArt($art) { $this->art = $art; } public function getArt() { return $this->art; } public function getId() { return $this->id; } } if (isset($_POST'speichern'])) { $neuesTier = new Tier( $_POST['name'], $_POST['alter'], $_POST['gewicht'], $_POST['geburtsdatum'], $_POST['art'] ); if (!isset($_SESSION['tiere'])) { $_SESSION['tiere'] = array(); } $_SESSION['tiere'] = $neuesTier; } if (isset($_POST['loeschen'])) { if (isset($_SESSION['tiere'])) { unset($_SESSION['tiere']); $_SESSION['tiere'] = array(); } } ?> Neues Tier hinzufügen Name: Alter: Gewicht (kg): Geburtsdatum: Art: Speichern Alle löschen Gespeicherte Tiere: 0) { foreach ($_SESSION['tiere'] as $tier) { echo "Tier: " . htmlspecialchars($tier->getName()) . ""; } } else { echo "Keine Tiere gespeichert."; } ?>
Submitted by anonymous
1

gamgamtestplf grundlegend

Created·2025-11-21 07:37
Flavor·PCRE2 (PHP)
setName($name); $this->setPrice($price); $this->setCategory($category); } // Getter und Setter public function getName(): string { return $this->name; } public function setName(string $name): void { $this->name = trim($name); } public function getPrice(): float { return $this->price; } public function setPrice(float $price): void { // einfache Validierung, minimum 0 if ($price price = $price; } public function getCategory(): string { return $this->category; } public function setCategory(string $category): void { $this->category = trim($category); } } // ---------- FORMULAR-AKTIONEN ---------- if ($_SERVER'REQUEST_METHOD'] === 'POST') { // Aktion unterscheiden: speichern oder alles löschen $action = $_POST['action'] ?? 'save'; if ($action === 'clear') { // Alle löschen $_SESSION['products'] = []; } else { // Speichern $name = $_POST['name'] ?? ''; $priceRaw = $_POST['price'] ?? '0'; $category = $_POST['category'] ?? ''; // number-Input kommt als String, in float wandeln $price = (float) str_replace(',', '.', $priceRaw); // Neues Objekt der Basisklasse erzeugen $product = new Product($name, $price, $category); // In Session-Array speichern, Key = uniqid() $id = uniqid('p_', true); $_SESSION['products' = $product; } // Optional: Redirect, um Formular-Resubmits zu vermeiden header('Location: ' . $_SERVER['PHP_SELF']); exit; } ?> Product Webapp body { font-family: Arial, sans-serif; margin: 20px; } form { margin-bottom: 20px; } label { display: block; margin-top: 10px; } input, select { padding: 5px; width: 250px; max-width: 100%; } button { margin-top: 15px; padding: 6px 12px; cursor: pointer; } table { border-collapse: collapse; margin-top: 20px; width: 100%; max-width: 600px; } th, td { border: 1px solid #ccc; padding: 8px; } th { background: #eee; } Produktverwaltung (Session-Demo) Produktname (type="text") Preis in € (type="number") Kategorie Elektronik Haushalt Bücher Sonstiges Speichern Alle löschen Gespeicherte Produkte (nur ein Feld wird ausgegeben) Produktname (eine Membervariable) $product): ?> getName(), ENT_QUOTES, 'UTF-8'); ?> Aktuell sind keine Produkte in der Session gespeichert.
Submitted by anonymous

Community Library Entry

0

Regular Expression
Created·2023-06-19 17:38
Flavor·Java

"
\b((0?[1-9]|[12][0-9]|3[01])[-/.\s](0?[1-9]|1[0-2])[-/.\s](19[0-9]{2}|200[0-9]))|((0?[1-9]|1[0-2])[-/.\s](0?[1-9]|[12][0-9]|3[01])[-/.\s](19[0-9]{2}|200[0-9]))|(([012][1-9]|3[01])(st|nd|rd|th)?\s(?i:Jan|Feb|Fév|Mar|Apr|Avr|May|Mai|Jun|Juin|Jul|Juil|Aug|Sep|Sept|Oct|Nov|Dec|Déc)\s(?:19[0-9]{2}|200[0-9]))|((?i:Jan|Feb|Fév|Mar|Apr|Avr|May|Mai|Jun|Juin|Jul|Juil|Aug|Sep|Sept|Oct|Nov|Dec|Déc)\s(?:0?[1-9]|[12][0-9]|3[01])(st|nd|rd|th)?\s(?:19[0-9]{2}|200[0-9]))|((0?[1-9]|[12][0-9]|3[01])(st|nd|rd|th)?\s(?i:January|janvier|February|fevrier|février|March|mars|April|avril|May|mai|June|juin|July|juillet|August|aout|août|September|septembre|October|octobre|November|novembre|December|décembre|decembre)\s(?:19[0-9]{2}|200[0-9]))|((?iu:January|janvier|February|fevrier|février|March|mars|April|avril|May|mai|June|juin|July|juillet|August|aout|août|September|septembre|October|octobre|November|novembre|December|décembre|decembre)\s(?:0?[1-9]|[12][0-9]|3[01])(st|nd|rd|th)?\s(?:19[0-9]{2}|200[0-9]))|(0?[1-9]|1[0-2])[-\/.\s](0?[1-9]|[12][0-9]|3[01])[-\/.\s](19|20)0[0-9]|(19|20)0[0-9][-\/.\s](0?[1-9]|1[0-2])[-\/.\s](0?[1-9]|[12][0-9]|3[01])\b
"
gm
Open regex in editor

Description

Covering Dates starting from year 2009 and older in French and English

Some of the valid Dates format April 2nd 2008 April 2 2008 April 02 2008 2009-01-01 31-03-2009 03-31-2009 31 March 2009 March 31 2009 31 mars 2009 May 10th 1989 April 2nd 2008 2009.01.01 2009 1 31 31st december 2009 31 décembre 2009 31 Decembre 2009 2009/02/01 2009.01.01 2009 01 01 31 03 2009 12 31 2009

Submitted by Francois-Alexandre Valade-Casaubon