Hacker News new | ask | show | jobs
by masklinn 4852 days ago
> most of them just look like cruddy PHP code.

Complete with extra syntax and forgetting your own tips from one example to the next:

> return ($string === "");

parens unnecessary:

    return $string === "";
> $ret = false; > if( time() > $end_time ){ > $ret = true; > } > return $ret;

aka

    return time() > $end_time;
> function ($string = null){ > if ($string == '' || null) return 'massage';

pretty sure he meant to say

    if ($string == '' || $string == null)
because there's not point to if (cond || null) since null is falsy, it's the exact same thing as if (cond)

> $data = include 'school_data.php';

Oh god, no…

> $data_update = $data + array( 'name' => 'surname', 'size' => 40 );

That's not an array update, since it doesn't update the first array.

> if(!is_array( $options )) $options = (array)$options;

That's absolutely horrible, you've got to know that contrary to what you might expect PHP doesn't convert a sequence of characters (a string) into an array of characters, but essentially does `array($options)` (create a 1-element array with the string). So write that.