This site uses cookies to improve your experience. To help us insure we adhere to various privacy regulations, please select your country/region of residence. If you do not select a country, we will assume you are from the United States. Select your Cookie Settings or view our Privacy Policy and Terms of Use.
Cookie Settings
Cookies and similar technologies are used on this website for proper function of the website, for tracking performance analytics and for marketing purposes. We and some of our third-party providers may use cookie data for various purposes. Please review the cookie settings below and choose your preference.
Used for the proper function of the website
Used for monitoring website traffic and interactions
Cookie Settings
Cookies and similar technologies are used on this website for proper function of the website, for tracking performance analytics and for marketing purposes. We and some of our third-party providers may use cookie data for various purposes. Please review the cookie settings below and choose your preference.
Strictly Necessary: Used for the proper function of the website
Performance/Analytics: Used for monitoring website traffic and interactions
Menno was reading through some PHP code and was happy to see that it was thoroughly commented: function degToRad ($value). return $value * (pi()/ 180 ); // convert excel timestamp to php date. }. " [Advertisement]. But I'm not sure how that comment came to be." Keep the plebs out of prod. Learn more.
Cassi ’s co-worker ( previously ) was writing some more PHP. Well, that seems like a perfect use case for PHP. "); n"; Now, PHP’s array_map is a beast of a function, and its documentation has some pretty atrocious examples. Lost my train of thought there when checking the PHP docs. Advertisement].
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.
Martin 's team had a problem in PHP. Being PHP, the empty function also doesn't check for empty strings, it checks for strings that can coerce to false (which includes the empty string, but also includes '0' ). See, the is_null function is, well, checking for nulls. It isn't checking for empty strings.
You see, Bert was a PHP developer. He was building a PHP application. But he copy/pasted Lisa's Java code into a PHP file, and then remangled it until it was executable PHP. Much of his frustration was rooted in the fact that her code didn't even run when he copy/pasted it into a PHP file. Advertisement].
Daniel spotted an array called $months in a PHP application. Advertisement] Continuously monitor your servers for configuration changes, and report when there's configuration drift. The data being stored in the array was some total of the sales of some commodity, for the past 5 months. That much all made sense.
On the other hand, submitter Born 2 Ruby, Forced 2 PHP was hired to work on a Ruby on Rails application, but after starting, discovered that the RoR app was an aspiration and the day to day work was to keep the legacy PHP application from falling over in production. Advertisement]. Keep the plebs out of prod. Learn more.
Dan was reviewing some PHP code written by a co-worker, as part of taking on a project. Advertisement]. The code was in “support” mode, rarely receiving changes, getting bug fixes only when absolutely necessary, and nobody really wanted to be the person responsible for it. This code had been in production for years. Learn more.
Mark worked with the kind of programmer who understood the nuances and flexibility of PHP on a level like none other. I'll let Mark explain: if it can't find a property called "otherWidgets", it uses PHP's magic __get , __set , and __call to create a call to getOtherWidgets. Advertisement] Picking up NuGet is easy.
For example, imagine you’re browsing a PHP codebase and see something like: $fmtedDate = data::now(); You’d instantly know that something was up, just by seeing a class named data. Advertisement]. That’s what got Vania ’s attention. She dug in, and found a few things. Download today!
Take Cassi , who needed to run some PHP software which depended on a few binaries and shell calls to do its job. output will always be an array, and even in PHP, an empty array is never going to equal zero. Advertisement]. Source control history can go a long way to telling a story. So this didn't work at all. Probably not.
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" ).
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.
"I have been meaning to send a card, but I just wasn't planning on using PHP's eval() to send it," Andrew wrote. . Advertisement]. writes, "I was trying to connect to PA VPN and it seems they think that downgrading my client software will help." " . "What "What the heck, Doordash?
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.
But the widget received a parameter from the HTML DOM, which itself was generated by PHP, and it didn't take long to find the SQL query it was using to find the next event: SELECT next_event FROM event_timer. Advertisement] Continuously monitor your servers for configuration changes, and report when there's configuration drift.
You’ll need a MySQL expert to work with databases, a PHP coder for a project with dynamic web pages, or someone who is knowledgeable with the Python language for a back-end project. You can then start advertising the position with a job description that is clear and accurate. Agree on how often you will communicate and give feedback.
Frankie was handed a pile of PHP and told, "Move this to a new host." Like a lot of PHP code, this code wasn't written. " [Advertisement]. " The process didn't go well- simply copying the code to the server chucked out a 500 error. So Frankie started digging into the code. It happened.
Take this delectable PHP nugget, from Nathaniel P , who has previously been tortured by bad date handling. Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Good method names are one of the primary ways to write self-documenting code. Honestly, this function needs to be delected.
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_.
writes, "Not sure whether this is supposed to be joke or is PHP really crashing its Wikipedia page." Advertisement]. . "While everybody is complaining about extreme shipping delays, my great grandmother is getting my Etsy order just in time for New Year's," wrote Gord S. . Explore how!
So many languages eschew "truth" for "truthiness" Today, we're looking at PHP's approach. PHP automatically coerces types to a boolean with some fairly simple rules: the boolean false is false the integer 0 is false, as is the float 0.0 In pure PHP, anything non-zero is true, but here only 1 is true.
Unrelated to this code, but a PHP weirdness, we pass the callable cmp as a string to the usort function to apply a sort. Every time I write a PHP article, I learn a new horror of the language, and "strings as callable objects" is definitely horrifying. Now, a moment ago, I said that we knew the format of the inputs.
This block of PHP code was simply copy/pasted everywhere it needed to be used, across multiple applications. Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. So let's take a look at how Pierre wrote code. Don't worry.
Finally, Mr. TA has found a possible explanation for a large portion of the content on this site, muttering "they should study the creators of PHP while they're at it" [Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. " XX is obviously 20, Jeppe.
This is the PHP code for handling checking out of their storefront: public function dispatch ( ) { try { if (! Here's hoping it's actually soon, and not the usage of "soon" where it's a synonym for "never" [Advertisement]. ProGet’s got you covered with security and access controls on your NuGet feeds.
There's a PHP front end, which also talks directly to the database, as well as a Java backend, which also talks to point-of-sale terminals. The PHP front end has code that looks like this: $sql = "select query from table where id=X" ; $result = mysql_query ( $sql ); //. Rui recently pulled an all-nighter on a new contract.
"Simple" for Bjørn is "do as much in PHP as possible since I am okay at PHP, including templating out JavaScript. Advertisement]. Sandra ( previously ) is still working with Bjørn. Bjørn also continues to like keeping things… simple. "Simple" This line exists, it doesn't work, and shouldn't be there.
Juliano had this very non-WTF bit of PHP code: if (! " [Advertisement] Otter - Provision your servers automatically without ever needing to log-in to a command prompt. I usually (but not always) avoid using those as WTFs. path && false) { //disabling this branch because X instead. But no, we did none of that.
You see, their PHP application allowed file uploads. PHP doesn't have a built in trunc method." " Pedantically true, as there's nothing called trunc or truncate in PHP, but it does have a floor and an intval method, both of which discard decimal digits (but behave slightly differently). Advertisement].
According to the PHP docs, any non-empty value means it's running on HTTPS, so it's technically an incorrect check. I strongly suspect, though, that it's a workaround for a badly behaving web server- I see a world where some server running PHP sets that variable to off or something equally inane, violating the spec.
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.
Bleu supports a Pimcore-based PHP site. Pimcore is a rather sprawling enterprise system for PHP. Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Like many Model-View-Controller type frameworks, maps HTTP requests to actions on controllers. Let's take a look at a few of them.
Pedro inherited a PHP application, and the previous developer had some opinions about how to handle arguments to functions. First, the $fullName line doesn't work as intended, since arrays in PHP are zero indexed. Advertisement]. ' $names [ 1 ]. ' ' ' $name [ 2 ]; return $names [ 0 ]. ' Am I an array?
It, ostensibly, contains some executable PHP code, which outputs some JavaScript into the body of the document. This lets you, in your eval , mix straight PHP and HTML content together: eval("if (foo) { ?> php }"); So you see, the developer responsible for this was being “smart”. Advertisement].
Now how would someone implement this complex formula in PHP? Advertisement] Continuously monitor your servers for configuration changes, and report when there's configuration drift. It's handling thousands of dollars of transactions a day, which isn't a huge amount, but it's certainly non-trivial.
"I guess they tried to indirectly measure the timespan between PHP versions," Martin writes. . Advertisement]. Sam writes, "You know.I think that I'm going switch to just plastic for a little while until this poor ATM gets itself sorted out." " . "I Get started today!
Pierre inherited a PHP application. The code is pretty standard stuff, for a long-living PHP application which has been touched by many developers with constantly shifting requirements. Advertisement]. Which is to say, it's a bit of a mess. But there's one interesting quirk that shows up in the codebase.
Well, because Mike has a co-worker that has read the docs well enough to know that PHP has a substr method, but not well enough to know it has an http_build_query method. Advertisement]. Or even an implode method , which handles string concats for you. '=' $val. '&' Get started today!
Imagine you're building a PHP web application, and you need to display different forms on different pages. Now, for most of us, we'd likely be using some framework to solve this problem, but even if we weren't, the obvious solution of "use a different PHP file for each screen" is a fairly obvious solution.
json = "{" ; Now, I know you're thinking, "I see a '$' sigil, this must be PHP or maybe Perl!" Advertisement] Picking up NuGet is easy. Today's anonymous submission is a delightfully simple line of JavaScript which really is an archetype of a representative line. " No, this is JavaScript.
Did I mention WordPress is built in PHP? Some rogue bit of PHP code had gone into a horrible loop, dumping out empty paragraph tags 131,074 times right before the footer element. Advertisement]. A fancy heading here, a custom font there. Pages upon pages of with nary a in sight. Download today!
Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. rmdir requires the target directory to be empty, so this recurses over all the files and subfolders in the directory, deleting them, so that we can delete the directory. Explore how!
It's that last optimization that's notable, just because the basic algorithm showed up here in 2005 - but in PHP. I hope and fear that some developer ported the PHP version to C# because they couldn't find a better option. Of course, all that effort, and they ignored the built-in TryParse.
We organize all of the trending information in your field so you don't have to. Join 49,000+ users and stay up to date on the latest articles your peers are reading.
You know about us, now we want to get to know you!
Let's personalize your content
Let's get even more personalized
We recognize your account from another site in our network, please click 'Send Email' below to continue with verifying your account and setting a password.
Let's personalize your content