Skip to content

u/random_son

In this archive from Oct 2020 to Jul 2026

1
posts
36
comments
0
media
191
score

Top posts

Generators vs. Fibers

I haven't used fibers so far. But I read about it an I have trouble to understand what the exact difference is between generators and fibers. I am stuck with the idea, that php 8.1 brought kind of abstractions around "yield" What is the difference, exactly?

7 points11 comments
Open on Reddit

Top comments

e.g. Java

Java and many other strongly typed programming languages give you the possibility to distinguish between "byte[]" and "string", where the type "string" usually "abstracts away" logic (e.g. for Unicode), which gets executed behind the scenes.

Now, since PHP has only "string" (so far (we are getting more and more typing, yay!)), it behaves as byte[] - e.g. hex2bin() or encryption related functions return or deal with raw byte[] data... A.k.a "string" in PHP for historical reasons. Changing the type "string" would break this. So, the quickest way to deal with Unicode strings without breaking stuff was to add mbstring. The other (more complete solution) would be to introduce strong typing, which would enable types like byte[].. we are not there yet

12 points

Subreddits

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.