szogyenyid

@szogyenyid@mastodon.social

Sustainability advocate creating a tech-driven green future. 🌱💻

Senior Engineer at LastPass, former startupper, software sustainability consultant.

This profile is from a federated server and may be incomplete. Browse more on the original instance.

aeveltstra, (edited ) to php
@aeveltstra@mastodon.social avatar

Remember, when you're programming a web application in #PHP, that the #MySQL backticks used in your #SQL cannot be used to fetch record fields in PHP.

PHP 7.5 doesn't throw an error on using backticks where one should be using quotes, when retrieving record fields. It simply returns null.

szogyenyid,

@aeveltstra What’s PHP 7.5? :D I’ve used backticks in queries in PHP8, worked perfectly.

szogyenyid, to webdev

To all the #webdev folks using #php in their stack. Did you know that using count($myArr) in your for loops' check uses almost twice as much energy than saving this value to a variable and using that one?

On my laptop, a for-loop used 0.79 Watts with a pre-calculated count(), and 1.51 Watts when calling the function in the loop's check.

You can measure it yourself with the tool I've written this weekend: https://github.com/szogyenyid/joulenne

#green #sustainability #sustainable #software

szogyenyid,

@ross I see that there could be non-trivial cases; eg. what happens if the size of the array gets modified in the loop, thus a count in every cycle would make sense?

I'm not sure how much AST-magic would be needed in order to detect these kind of scenarios.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • JUstTest
  • mdbf
  • ngwrru68w68
  • modclub
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • InstantRegret
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • DreamBathrooms
  • megavids
  • GTA5RPClips
  • tacticalgear
  • normalnudes
  • tester
  • osvaldo12
  • everett
  • cubers
  • ethstaker
  • anitta
  • provamag3
  • Leos
  • cisconetworking
  • lostlight
  • All magazines