Skip to content

Instantly share code, notes, and snippets.

@tops
tops / parser.php
Created May 9, 2017 13:31
Split markdown by heading 1 in PHP
<?php
$md = "
hej
# Rubrik 1
hej hej
## underrubrik
@tops
tops / bikerental.sql
Created March 1, 2017 11:00
FE16 - koden från lektionen 170227
-- Adminer 4.2.3 MySQL dump
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
CREATE DATABASE `bikerental` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `bikerental`;
@tops
tops / add.php
Created February 13, 2017 20:34
Simple React Demo - Todo-list
<?php
$db = mysqli_connect("localhost","root","root","todo");
mysqli_query($db,"SET NAMES utf8");
$query = "INSERT INTO items (title) VALUES ('{$_GET['title']}')";
$result = mysqli_query($db, $query);
echo json_encode(["id" => mysqli_insert_id($db), "title" => $_GET['title']]);
@tops
tops / api.class.php
Created January 24, 2017 09:16
Objektorienterat enkelt REST-API i PHP
<?php
#
# Den här klassen startar upp vårt API och hämtar allt det vi behöver från själva HTTP-anropet
#
class API{
private $method, // GET, POSt, PUT, DELETE ...
$input, // Data sent with request
$resource, // REST Resource to call
@tops
tops / index.php
Created January 16, 2017 16:43
Simple RESTish API in PHP
<?php
/* =======================
== GET REQUEST STUFF
In this section of the code we get all the parts of the HTTP request to handle if and do the right stuff in the backend.
======================= */
// GET THE REQUEST METHOD
$method = $_SERVER['REQUEST_METHOD'];