Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 21, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 21, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 21, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 21, 2025

      Helldivers 2: Heart of Democracy update is live, and you need to jump in to save Super Earth from the Illuminate

      May 20, 2025

      Qualcomm’s new Adreno Control Panel will let you fine-tune the GPU for certain games on Snapdragon X Elite devices

      May 20, 2025

      Samsung takes on LG’s best gaming TVs — adds NVIDIA G-SYNC support to 2025 flagship

      May 20, 2025

      The biggest unanswered questions about Xbox’s next-gen consoles

      May 20, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Handle Fluent Values as Arrays with Laravel’s array() Method

      May 21, 2025
      Recent

      Handle Fluent Values as Arrays with Laravel’s array() Method

      May 21, 2025

      Locale-aware Number Parsing in Laravel 12.15

      May 21, 2025

      HCL Commerce V9.1 – The Power of HCL Commerce Search

      May 20, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Use Multi-Cursor in VS Code to Edit Multiple Lines Simultaneously

      May 21, 2025
      Recent

      Use Multi-Cursor in VS Code to Edit Multiple Lines Simultaneously

      May 21, 2025

      JamesDSP is an audio effect processor for Pipewire

      May 21, 2025

      shadPS4 is a cross-platform PlayStation 4 emulator

      May 21, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»Representative Line: Get Explosive

    Representative Line: Get Explosive

    April 3, 2025

    Sean sends us a one-line function that is a delight, if by delight you mean “horror”. You’ll be shocked to know it’s PHP.

    function proget(){foreach($_GET as $k=>$v){if($k=="h"){$GLOBALS["h"]=1;}$p=explode(",",$k);}return($p);} //function to process GET headers
    

    Based on the comment, proget is a shorthand for process_get_parameters. Which is sort of what it does. Sort of.

    Let’s go through this. We iterate across our $_GET parameters using $k for the key, $v for the value, but we never reference the value so forget it exists. We’re iterating across every key. The first thing we check is if a key "h" exists. We don’t look at its value, we just check if it exists, and if it does, we set a global variable. And this, right here, is enough for this to be a WTF. The logic of “set a global variable based on the existence of a query parameter regardless of the value of the query parameter” is… a lot. But then, somehow, this actually gets more out there.

    We explode the key on commas (explode being PHP’s much cooler name for split), which implies… our keys may be lists of values? Which I feel like is an example of someone not understanding what a “key” is. But worse than that, we just do this for every key, and return the results of performing that operation on the last key. Which means that if this function is doing anything at all, it’s entirely dependent on the order of the keys. Which, PHP does order the keys by the order they’re added, which I take to mean that if the URL has query params like ?foo=1&h=0&a,b,c,d=wtf. Or, if we’re being picky about encoding, ?foo=1&h=0&a%2Cb%2Cc%2Cd=wtf. The only good news here is that PHP handles the encoding/decoding for you, so the explode will work as expected.

    This is the kind of bad code that leaves me with lots of questions, and I’m not sure I want any of the answers. How did this happen, and why are questions best left unanswered, because I think the answers might cause more harm.

    [Advertisement] Plan Your .NET 9 Migration with Confidence
    Your journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleFOSS Weekly #25.14: Fedora 42 COSMIC, OnePackage, AppImage Tools and More Linux Stuff
    Next Article Rilasciato Qt 6.9: il framework per interfacce grafiche si aggiorna con prestazioni potenziate e nuovo supporto emoji

    Related Posts

    News & Updates

    Helldivers 2: Heart of Democracy update is live, and you need to jump in to save Super Earth from the Illuminate

    May 20, 2025
    News & Updates

    Qualcomm’s new Adreno Control Panel will let you fine-tune the GPU for certain games on Snapdragon X Elite devices

    May 20, 2025
    Leave A Reply Cancel Reply

    Hostinger

    Continue Reading

    Meta’s SAM 2 model enables accurate video segmentation in seconds

    Artificial Intelligence

    Smashing Security podcast #373: iPhone undeleted photos, and stealing Scarlett Johansson’s voice

    Development

    Executive Conversations: Putting generative AI to work in omnichannel customer service with Prashanth Singh, Chief Operating Officer at LeadSquared

    Databases

    I’ve tested dozens of MagSafe wallets, but this is the most premium one yet

    Development

    Highlights

    12 useful features Google just announced for Pixel phones, watches, and tablets

    June 11, 2024

    From enhanced Find My Device to recorder summaries, Pixel users are getting some exciting new…

    How to Upgrade MuleSoft APIs to Java 17: A Comprehensive Guide

    January 9, 2025

    Ascension Makes Progress in Restoring Systems After Cyberattack, Patients to See Improved Wait Times

    June 11, 2024

    Hacking of Ewon Cosy+ Secure Industrial Remote Access Gateway is Possible

    August 13, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.