Skip to content

Instantly share code, notes, and snippets.

@jeremykendall
jeremykendall / debug-functions.php
Created October 30, 2012 14:56
Global debug functions
/**
* Dumps information about a variable. Convenience wrapper for var_dump()
*
* @param mixed $expression The variable you want to dump.
* @param mixed $expression,... unlimited OPTIONAL number of additional variables to display with d()
* @return void
*/
function d($expression) {
var_dump($expression);
}
<?php
function multiple_cycle($limit, $numbers)
{
$count = 0;
$index = 0;
$numbersLength = count($numbers);
for ($i = 1; $i <= $limit; $i++) {
if ($i % $numbers[$index] == 0) {
@jeremykendall
jeremykendall / zf-validate-issue.php
Created August 27, 2012 16:46
First Zend_Validate_Db_NoRecordExists validator is ignored
$this->addElement('text', 'email', array(
'label' => 'Your email address',
'required' => true,
'validators' => array(
array('EmailAddress'),
array(
new \Zend_Validate_Db_NoRecordExists(array('table' => 'accounts', 'field' => 'email')),
'breakChainOnFailure' => true
),
array(new \Zend_Validate_Db_NoRecordExists(array('table' => 'beta_invites', 'field' => 'email')))
@jeremykendall
jeremykendall / KingDiamondTest.php
Created March 18, 2012 06:10
Tests the major plot point of Mercyful Fate's tune Melissa
<?php
namespace MercyfulFate;
use MercyfulFate\KingDiamond;
class KingDiamondTest extends \PHPUnit_Framework_TestCase
{
/**
* @var MercyfulFate\Priest
*/
<?php
echo "Hello world";