Skip to content

Instantly share code, notes, and snippets.

View comments.php
<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) {
View gist:1704335
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
Multidimensional Array
View data-array.php
<?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 Jun 14, 2012
PHP 5.3 vs PHP 5.4
View gist:2928842
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
View gist:3227011
<?php
Interface WeatherInterface {
public function getWeather();
}
class WeatherBot implements WeatherInterface {
public function getWeather() {
// imagine something more complicated
return 'Sunny';
View gist:3654430
sudo http_proxy="http://wwwcache.lmu.ac.uk:3128" aptitude install curl
# add to .bashrc:
export http_proxy="http://wwwcache.lmu.ac.uk:3128"
View gist:3756788
<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 Sep 25, 2012
an API-created gist
View file1.txt
Some lovely code, how nice!
View gist:4131314
<?php
// phpinfo();
echo "verb: " . $_SERVER['REQUEST_METHOD'] . "\n";
echo "headers:";
var_dump(apache_request_headers());
echo "\n";
@lornajane
lornajane / text.txt
Created Dec 20, 2012
Gist created by API
View text.txt
Some riveting text