Feed aggregator
Telegram Allows Private Chat Reports After Founder's Arrest
Read more of this story at Slashdot.
US, UK, EU Sign 'Legally Binding' AI Treaty
Read more of this story at Slashdot.
Android Earthquake Alerts Now Available Across All 50 States, 6 US Territories
Read more of this story at Slashdot.
AT&T Sues Broadcom For Breaching VMware Support Extension Contract
Read more of this story at Slashdot.
New AI Model 'Learns' How To Simulate Super Mario Bros. From Video Footage
Read more of this story at Slashdot.
Snap Sued Over 'Sextortion' of Kids By Predators
Read more of this story at Slashdot.
Apple Announces 'Find My' For South Korea
Read more of this story at Slashdot.
Uniswap Labs Beset By Regulators For Building a Decentralized Exchange
Read more of this story at Slashdot.
Verizon To Buy Frontier For $9.6 Billion, Says It Will Expand Fiber Network
Read more of this story at Slashdot.
OpenAI Considering Monthly Subscription Prices as High as $2000 for New AI Models
Read more of this story at Slashdot.
Visa Debuts New Product Designed To Make It Safer To Pay Directly From Bank Account
Read more of this story at Slashdot.
Bluetooth Upgrade Boosts Precision Tracking and Device Efficiency
Read more of this story at Slashdot.
Madrid Bans Hired E-scooters Over Safety Concerns
Read more of this story at Slashdot.
UK Competition and Markets Authority Launches Investigation Into Ticketmaster
Read more of this story at Slashdot.
Leaked Disney Data Reveals Financial and Strategy Secrets
Read more of this story at Slashdot.
Feds Indict Musician on Landmark Massive Streaming Fraud Charges
Read more of this story at Slashdot.
Deutsche Bank Chief Tells Germans: Work Longer and Harder
Read more of this story at Slashdot.
Discord Lowers Free Upload Limit To 10MB
Read more of this story at Slashdot.
Saturn's Rings Will Vanish Temporarily In Six Months
Read more of this story at Slashdot.
CodeSOD: Strings go Asplodey
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. You want to split a string? We call that explode because that's way more radical than split. Want to join a string back together? We use implode, because that's the opposite of explode.
Or, if you forget how to use implode, you could always write it yourself, which is what Anton found in the codebase:
<?php $flag = false ?> <?php echo $this->__('Your order number is ') ?> <?php foreach ($_orderIds as $orderId=>$incrementId): ?> <?php if ($flag): ?> <?php echo ', ' ?> <?php endif; ?> <?php $flag = true ?> <a href="<?php echo $this->getViewOrderUrl($orderId) ?>"><?php echo $incrementId ?></a> <?php endforeach; ?>Now, as "we reimplemented a built-in function" standards, this isn't the worst instance of that logic. The basic "for loop, with a flag to help you remember if you should add a comma or not," isn't absurd.
No, the real ugly I see here is the (ab)use of PHP's interpretation. Every statement is wrapped in its own <?php ?> block, which is not necessary, and certainly makes the code less readable. The whole (dubious) advantage of PHP is that you can mix code with literal HTML output. There's no reason to <?php echo ', '?> when we could just output a , and a space directly in the page. Or conversely, we could put most of the logic inside of a single <?php ?> block and echo as needed to generate output, since we're doing echos for pretty much everything anyway.
All in all, it's just ugly code. Widely used ugly code. (Or at least was widely used when Anton submitted this, which was some time ago- we could hope the code has been improved since then)
[Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.