DEV Community

loading...

Discussion on: Why PHP 8 will be awesome

Collapse
kirkhilles profile image
kirkhilles

I'm a software developer by trade, but I'm NOT an Engineer. My interest is to have code that's simple, easy to follow, easy to maintain and efficient. I -detest- the word "elegant". If my code were a car, it'd be a Honda. Simple. Bulletproof. Effective. Reliable. Too many programmers want to over-engineer. The complexity of code is their pride. Their code is like a BMW. When it works, it's very nice but after awhile you just throw it away because it's a mess to work on.

So, in terms of the "@" sign, I understand the arguments. I get how some people might be excited about it going away. But to me, it's very effective to use in the REAL WORLD. I use this code all day long:

$sVar = @$_REQUEST["sVar"];

It allows me the ideal situation of having just that one clean line and then I can check to see if sVar has a value throughout the code. Why do I need to check to see if it exists first? Why is this code considered "better"?

$sValue = "";
if (isset($_REQUEST["sVar"])) $sValue = $_REQUEST["sVar"];

The original code is cleaner, easier to read and provides the exact same results as the second without you having to specify "$_REQUEST" 2x and "$sValue" 2x.

I get it and I know that I'm "wrong", but it drives me nuts when there are "breaking" changes in a version. That's just not a philosophy I agree with. I understand why it went "mysql_query($sql, $conn)" to "mysqli_query($conn, $sql)" and how i I deally you'd have everything separated into separate functions and only have to update it once, but in the REAL WORLD sometimes that doesn't happen that way and you have to go and update thousands of references because a PHP architect decided a philosophy change was needed. Why do things have to be depreciated?

Again, I don't need to be told why "I'm wrong". I'm interested in the end solution and not with the latest and greatest coding design and from my perspective, the end justifies the means. If it were up to me, I would design all future versions of a language where the latest builds still work with coding from version 1.x.

Anyway, end of rant LOL.

Collapse
jmau111 profile image
Julien Maury Author

maybe you can use the syntactic sugar $var = $_REQUEST["sVar"] ?? ""; instead.

Breaking changes are something to consider as a last resort, but sometimes it makes sense.

Forem Open with the Forem app