Tinkerwell 4 is out now! See what's new or buy now.
Tinkerwell background image
Tinkerwell Logo Tinkerwell

Magic Comments

Magic Comments allow you to inspect the content of variables during runtime – like a complex debugging solution. They are a unique feature of Tinkerwell and they aren’t available in any other code runner in this form.

You can use them to display the state of variables and objects during the code execution. This is useful for debugging scripts, simplify coding challenges or you can use them permanently within Tinkerwell Snippets.


The //? at the end of a line returns the value of this line. This is easier to understand when looking at the next screenshot.

$result = 1+1; //?
$result += 1; //?
$result += 1; //?

Tinkerwell prints out the result of each line and ends with the normal output within the output panel.


While the //? comment comes very handy, the /?->/ is the real deal. It allows your to run methods or access properties while your code runs without changing the output of the overall script.

The following snippets uses the count() method of Laravel Eloquent to count the number of Tinkerwell users and adds a second query for the number of active users – the ones who validated their Tinkerwell license within the last 30 days.

AppLicense::where('app_id', 1)
/*?->count()*/ // Total Tinkerwell Users:
->where('last_validated_at', '>', now()->subDays(30))
/*?->count()*/; // Active Users in the last 30 days:

As you can see, there is a core group of developers who use Tinkerwell very regularly. These are usually the ones who learned how to use the app with all its benefits and stick with it for a long time.

Sometimes, it’s helpful to understand what your code does while it runs. This is helpful if you work with complex queries or collections and want to understand how filters and other methods work on your data.

The following example fetches a list of public repositories from GitHub, filters for all repositories that are Laravel related and maps them to their name only. During the code execution, Tinkerwell displays the number of all repositories, the number of filtered repositories and even all repository names while the filter runs.

Simply copy the code to the default app of your Tinkerwell app and play around with the GitHub API to learn how to use Magic Comments in Tinkerwell.

) /*?->count()*/
->filter(function ($repo) {
$repo['full_name']; //?
return Str::contains($repo['full_name'], 'laravel');
->map(function ($repo) {
return $repo['full_name'];
Mohamed Said, VP of Engineering at Foodics
“I don't know why anyone wouldn’t use Tinkerwell. I can't even remember how I used to test code on the go before it.”

Mohamed Said

VP of Engineering at Foodics

Luke Hebblethwaite, Developer
“Testing code, writing one-off scripts, or just playing with random logic is far easier with Tinkerwell. Its one of the best purchases I've made in my career.”
Luke Hebblethwaite


Tinkerwell: The PHP Scratchpad

The must-have companion to your favorite IDE. Quickly iterate on PHP code within the context of your web application.

Buy now Learn more