![]() |
Einbinden von PHP in html |
---|---|
html knowhow | |
Erklärung |
---|
Java kann man gründsätzlich auf vier Arten in eine html-Seite einbauen: 1. Vor dem !DOCTYPE oder 2. Als externe Datei im head oder 3. Als externe "Datei" im body oder 4. Als interne "Datei" im body |
Quellcode |
1. Vor dem !DOCTYPE <?php // Dateipfad $id = basename($_SERVER['SCRIPT_NAME']); // Pfad zum Protokoll $protokoll = __DIR__ . '/protokoll-'.$id.'.txt'; // Check, ob Textdatei vorhanden. Wenn nicht, wird eine erstellt mit 0 erstellt if (!file_exists($protokoll)) ?> 2. Als externe Datei im head <?php include("../includes/nav.php") ?> <meta name="description" content="<?php echo $description ?>"> 3. Als externe "Datei" im body <?php include ("header.php"); ?> 4. Als interne "Datei" im body <?php // Dateipfad $id = basename($_SERVER['SCRIPT_NAME']); // Pfad zum Protokoll $protokoll = __DIR__ . '/protokoll-'.$id.'.txt'; // Check, ob Textdatei vorhanden. Wenn nicht, wird eine erstellt mit 0 erstellt if (!file_exists($protokoll)) ?> |
|