Skip to content

Instantly share code, notes, and snippets.

@lornajane
lornajane / comments.php
Created August 16, 2011 13:09
comments
<h1>Submit A Comment</h1>
<form method="post">
<p>Name: <input name="name" /></p>
<p>Comment: <textarea name="comment"></textarea></p>
<input type="submit" />
</form>
<?php
if($_POST) {
foreach ($thing as $value) {
if(!empty($value)) {
if(is_array($value)) {
foreach($value as $subitem) {
$array[] = $subitem;
}
} else {
$array[] = $value;
}
}
@lornajane
lornajane / data-array.php
Created May 28, 2012 15:08
Multidimensional Array
<?php
$events[] = array(
"name" => "phpDay 2012",
"start_date" => "2012-05-18T00:00:00+02:00",
"end_date" => "2012-05-19T23:59:59+02:00",
"description" => "The GrUSP, the Italian PHP user group, organises the 8th phpDay, a conference dedicated to PHP for the enterprise.",
"href" => "http://www.phpday.it",
"hosts" => array(
"Daniel Londero",
@lornajane
lornajane / gist:2928842
Created June 14, 2012 07:45
PHP 5.3 vs PHP 5.4
5.3.12 5.4.3
Run 1 2.07883811 0.94130707
Run 2 2.03927302 0.96553779
Run 3 2.03478503 0.96503210
Run 4 2.05938697 0.94606614
Run 5 2.04912210 0.95049596
<?php
Interface WeatherInterface {
public function getWeather();
}
class WeatherBot implements WeatherInterface {
public function getWeather() {
// imagine something more complicated
return 'Sunny';
sudo http_proxy="http://wwwcache.lmu.ac.uk:3128" aptitude install curl
# add to .bashrc:
export http_proxy="http://wwwcache.lmu.ac.uk:3128"
@lornajane
lornajane / gist:3756788
Created September 20, 2012 16:03
My First Form
<form method="post">
Name: <input type="text" name="name" />
<br />
<input type="submit" />
</form>
<?
if($_POST) {
echo "Hello, " . filter_input(INPUT_POST, "name", FILTER_SANITIZE_STRING);
@lornajane
lornajane / file1.txt
Created September 25, 2012 12:00
an API-created gist
Some lovely code, how nice!
@lornajane
lornajane / gist:4131314
Created November 22, 2012 14:01
localhost index
<?php
// phpinfo();
echo "verb: " . $_SERVER['REQUEST_METHOD'] . "\n";
echo "headers:";
var_dump(apache_request_headers());
echo "\n";
@lornajane
lornajane / text.txt
Created December 20, 2012 15:37
Gist created by API
Some riveting text