Recall & Review
beginner
What is a Fiber in PHP?
A Fiber is a lightweight concurrency primitive that allows you to pause and resume code execution, enabling cooperative multitasking within a single thread.
Click to reveal answer
beginner
How do you create and start a Fiber in PHP?
You create a Fiber by instantiating the Fiber class with a callable, then start it using the start() method, which runs the fiber until it suspends or finishes.Click to reveal answer
intermediate
What method do you use to pause a Fiber's execution?
You use the Fiber::suspend() method inside the fiber's callable to pause execution and optionally send a value back to the caller.
Click to reveal answer
intermediate
How do you resume a suspended Fiber?
You call the resume() method on the Fiber instance, optionally passing a value that the fiber receives as the result of the suspend() call.
Click to reveal answer
intermediate
Why are Fibers useful for concurrency in PHP?
Fibers let you write asynchronous code in a synchronous style by pausing and resuming tasks cooperatively, improving readability and control without using multiple threads.Click to reveal answer
Which PHP class is used to create a Fiber?
✗ Incorrect
The Fiber class is the built-in PHP class used to create fibers for concurrency.
What method starts the execution of a Fiber?
✗ Incorrect
The start() method begins the execution of a Fiber.
How does a Fiber pause its execution?
✗ Incorrect
Fibers pause execution by calling Fiber::suspend() inside their callable.
What happens when you call resume() on a Fiber?
✗ Incorrect
Calling resume() continues the Fiber's execution from where it was suspended.
Fibers in PHP help achieve concurrency by:
✗ Incorrect
Fibers allow cooperative multitasking by pausing and resuming code within a single thread.
Explain how Fibers enable concurrency in PHP and how you control their execution.
Think about how you can stop and start a task manually inside one thread.
You got /4 concepts.
Describe the lifecycle of a Fiber from creation to completion.
Consider the steps you take to run, pause, and finish a Fiber.
You got /5 concepts.