Skip to content

Instantly share code, notes, and snippets.

View tbreuss's full-sized avatar
🚴‍♂️
Biking

tebe tbreuss

🚴‍♂️
Biking
View GitHub Profile
@tbreuss
tbreuss / SymfonyEventDispatcherExample.php
Created August 25, 2014 15:57
A very simple example using the Symfony EventDispatcher component.
<?php
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class MyListener
{
public function onFooAction(Event $event)
@tbreuss
tbreuss / is_natural.php
Created April 10, 2014 19:15
A simple function to recognize whether the value is a natural number.
<?php
function is_natural($val, $acceptzero = false)
{
$return = ((string) $val === (string) (int) $val);
if ($acceptzero) {
$base = 0;
} else {
$base = 1;
}