Skip to content

Instantly share code, notes, and snippets.

View gooh's full-sized avatar

Gordon Oheim gooh

View GitHub Profile
@gooh
gooh / Dirty Casting
Last active December 13, 2015 18:39
Here be dragons and black magic!
<?php
class Caster
{
/**
* Casts an Array to an instance of a class
*
* This method will return an instance of the given $className with all
* elements in the array being public members of the instance. The method
* uses serialization to work, so no constructor will be called to get the
* instance of $className. The returned instance may behave unexpectedly
@gooh
gooh / xpath_match_all
Last active September 28, 2015 00:48
function for people whining that preg_match_all is less to type and concluding from it that regex must be better for parsing html than a dom parser
<?php
/**
* Run an XPath query against an HTML string and returns the results
*
* @param string $xpath The XPath query to run on $thml
* @param string $html The HTML to parse. Uses the previously used string if omitted
* @return array
*/
function xpath_match_all($query, $html = '')
{
@gooh
gooh / php_errors.txt
Created July 27, 2011 16:23 — forked from ircmaxell/php_errors.txt
All errors in the 5.3 source code tree (zend_error|php_error_docref)
./ext/bcmath/bcmath.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero");
./ext/bcmath/bcmath.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero");
./ext/bcmath/bcmath.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Square root of negative number");
./ext/bz2/bz2.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "length may not be negative");
./ext/bz2/bz2.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "could not read valid bz2 data from stream");
./ext/bz2/bz2.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "'%s' is not a valid mode for bzopen(). Only 'w' and 'r' are supported.", mode);
./ext/bz2/bz2.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "filename cannot be empty");
./ext/bz2/bz2.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot use stream opened in mode '%s'", stream->mode);
./ext/bz2/bz2.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot use stream opened in mode '%s'", stream->mode);