article thumbnail

CodeSOD: PHP Error Logging

The Daily WTF

Today's anonymous submitter sends us some PHP exception logging code. This particular code shows a surprising understanding of some clever PHP tricks. They opted to use var_dump , a handy PHP debugging function which dumps an object's properties to the output buffer. Unfortunately, everything about it is still wrong.

PHP 59
article thumbnail

CodeSOD: JaphpaScript

The Daily WTF

The loop is executed in PHP, and "rendered" in JavaScript, outputting a huge pile of array assignments. The loop is executed in PHP, and "rendered" in JavaScript, outputting a huge pile of array assignments. Worse than that, even the name of the variable is generated in PHP- group_Arr_.

PHP 64
Insiders

Sign Up for our Newsletter

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Trending Sources

article thumbnail

CodeSOD: Strings go Asplodey

The Daily WTF

Anton has the joy of doing PHP work using one of the more popular e-commerce platforms. Now, say what you will about PHP, its absolute mess of a root namespace has a function or class for just about everything. No, the real ugly I see here is the (ab)use of PHP's interpretation. You want to split a string? Learn more.

PHP 64
article thumbnail

CodeSOD: False True is True False

The Daily WTF

We see this all the time in JavaScript, and of course, in PHP. PHP booleans, for example, can surprise you: 0 is false, which is a common enough assumption, but so is "0" - the string zero. These are, in PHP-land, both true. Which, if you don't know much about PHP, feels necessary. As are empty arrays.

PHP 64
article thumbnail

CodeSOD: Time to Change

The Daily WTF

Notably, PHP pins the Unix timestamp to UTC+00:00, aka GMT. Advertisement] Keep the plebs out of prod. Dennis found this little nugget in an application he inherited. gmdate then formats that, with the assumption that the time is in GMT. strtotime then parses that string back into a timestamp, and returns that timestamp.

PHP 59
article thumbnail

CodeSOD: Metaception

The Daily WTF

But if you're using PHP and JavaScript, there's good odds that someone you work with has decided to combine these two tastes together to create something nobody wants to taste. > We start with some HTML which wraps some PHP code. A more extreme version happened to our anonymous submitter. closest ( "tr" ).

PHP 69
article thumbnail

CodeSOD: Pay for this Later

The Daily WTF

And it's not like this needs to be implemented from scratch- PHP has built-in XML parsing classes. It's always amazing when TRWTF is neither PHP nor XML but… whatever this is.

PHP 59