Replies

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

dseguy, to php French
@dseguy@phpc.social avatar

question of the day : when you know that
2*2 = 4
2^2 = 4 (too)
2.5^2.5 = 9.8821176880262..

Where is this 6 coming from ?

dseguy,
@dseguy@phpc.social avatar

@arnan This starts with floats, but ends with integer.

dseguy,
@dseguy@phpc.social avatar

@derickr The first print shows 4, the second one says 6.

dseguy,
@dseguy@phpc.social avatar

@JerryWham The first print shows 4, the second one shows 6.

dseguy, to php French
@dseguy@phpc.social avatar

#PHP doesn't allow float as index in arrays.

It is possible to use them as such by casting them to string. Later, type juggling will allow adding to another float, seamlessly.

#phptip #phptrick

https://php-tips.readthedocs.io/en/latest/tips/store_float_as_index.html

dseguy,
@dseguy@phpc.social avatar

@mitelg mea culpa, it was seamless in the case I was working on.

With a finite float, it works.

With calculated float, there are possible hidden decimals : https://3v4l.org/dJ0mP;

It will loose precision with the default 'precision' (the directive), but not with higher levels (due to truncation).

nixCraft, to random
@nixCraft@mastodon.social avatar

PHP was originally an abbreviation of Personal Home Page 🤔 did you know that?

dseguy,
@dseguy@phpc.social avatar

@nixCraft Indeed. It also means a lot of other things, funny or downright serious.

https://www.exakat.io/en/what-does-php-mean/

dseguy, to php French
@dseguy@phpc.social avatar

I finally found an occurrence of this beauty :

$this->$this

It still looks like a typo in the original code, but with the help of __toString, it works. Also, strict_types doesn't help here.

https://php-tips.readthedocs.io/en/latest/tips/this_this.html and more tips!

dseguy,
@dseguy@phpc.social avatar

@Crell I knew that trick for a while now, but I only found it in actual code yesterday.

One less to find in the wild, still waiting for a few of them to appear.

"If there is a mean, there is a will."

dseguy,
@dseguy@phpc.social avatar

@ocramius 'that was not a question' (tm)

dseguy,
@dseguy@phpc.social avatar

@NanoSector it took me a few years to find one in the wild. You can relax.

dseguy,
@dseguy@phpc.social avatar

@asgrim @ocramius This was not a question!

dseguy,
@dseguy@phpc.social avatar

@pollita Coming from you, I take it as a compliment. Thanks 😎

dseguy,
@dseguy@phpc.social avatar

@wez Touché.

dseguy,
@dseguy@phpc.social avatar

@edorian Always a pleasure.

As long as I don't find this in your code, of course. 😂

dseguy,
@dseguy@phpc.social avatar

@heiglandreas 😂 :elephpant:

dseguy, to php French
@dseguy@phpc.social avatar
  1. it is possible to call a method 'as', because relaxed keywords methods

  2. it is possible to import a method from a trait, and alias it to itself.

It is possible to write 'as as as ' in and make sense.

https://php-tips.readthedocs.io/en/latest/tips/as-as-as.html

dseguy,
@dseguy@phpc.social avatar

@gmazzap 😂 😂
I just love it when using actual syntax to spell out a human readable message.

dseguy,
@dseguy@phpc.social avatar

@alessandrolai 😮 Aliased constructor...!! I might have overlooked that one.

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