Last active
December 28, 2015 10:29
-
-
Save mattneary/7486957 to your computer and use it in GitHub Desktop.
Shitty PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
/* | |
PHP takes the design of Perl (ugly), the interfaces | |
of C (low-level and clunky), and the OO of C++ | |
(an impure mess). Some things are completely broken, | |
and every API is either inconsistent or just | |
inconvenient. | |
Its only utility is its output of inline text, which | |
is convenient for mostly-text websites with some functionality, | |
but terrible for well-designed programs, interweaving | |
functionality and views at a fundamental level. | |
*/ | |
// Completely Broken Things | |
// ======================== | |
/* | |
When an undefined variable is passed as argument to | |
a function, it is instantiated. Even worse, when an | |
accessor on an undefined object is passed, it too is | |
instantiated. | |
*/ | |
function undefined_ref_is_instantiated_with_key(&$a) {} | |
undefined_ref_is_instantiated_with_key($x['foo']); | |
// => $x = { foo => NULL } | |
/* | |
When an array with a string that looks like a number | |
is checked for the presence of another string, one | |
looking like an equivalent number, it is "found". | |
*/ | |
function string_is_found_present_when_numbers_are_equal() { | |
$arr = array('7.1'); | |
$found = in_array('7.10', $arr); | |
// => $found = true | |
} | |
// Terrible Design | |
// =============== | |
function inconsistent_names() { | |
base64_encode(""); | |
urlencode(""); | |
deg2rad(12); | |
strtotime("10:30"); | |
// These are inverses! | |
$encoded = htmlentities("<abc>"); | |
html_entity_decode($encoded); | |
} | |
function random_argument_order() { | |
array_filter($callback, $arr); | |
array_map($arr, $callback); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment