Skip to content

Instantly share code, notes, and snippets.

View steffengrahl's full-sized avatar

Steffen Grahl steffengrahl

View GitHub Profile
@steffengrahl
steffengrahl / api.php
Created October 24, 2021 16:07
Ganz einfaches Beispiel um Daten an eine Api zu senden und die response der Api auszugeben.
<?php
try {
$data = json_decode($_POST['data'], true, 512, JSON_THROW_ON_ERROR);
header('Content-Type: application/json; charset=utf-8');
echo json_encode(
['message' => 'Ich hab folgende Daten empfangen ' . json_encode($data, JSON_THROW_ON_ERROR)],
JSON_THROW_ON_ERROR
);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP - Ordner auslesen und anzeigen</title>
<style type="text/css">
ul#galerie {
padding:0;
margin:0;
list-style-type:none;
<?php
session_start();
echo "<pre>";
printf("willkommen auf der geheimen Seite.\n\ndeine user-id ist %s", $_SESSION['userid']);
echo "</pre>";
<div class="wrapper">
<?php
while($tom = mysqli_fetch_array($pinky, MYSQL_ASSOC))
{
echo '
<div class="container">
<div id="container_inner">
<p>
<img src="fotos/240x180.gif" width="104" height="90" style="float:right; margin: 10px;">';
echo substr($tom['text'],0 ,400 );
<pre>
<?php
echo $_SERVER['HTTP_USER_AGENT']."\n\n";
if (strstr($_SERVER['HTTP_USER_AGENT'], 'Mozilla')) {
echo "gefunden\n";
} else {
echo "nicht gefunden\n";
}
?>
<?php
error_reporting(E_ALL);
if (isset($_POST['submit'])) {
$email = '';
$username = '';
$passwort = '';
$passwort2 = '';
<form action="{{form_uri}}" method="post">
<label for="ort">Ort</label>
<input type="text" name="ort" id="ort" value="{{ort}}">
<input type="submit">
</form>
<?php
function foo() {
return (1 + 2);
}
function bar($a) {
return ($a + 3);
}