Skip to content
Gallery

PHP

Celsius to Fahrenheit

10 lines 1 view by Md Shamim Hossain · published 26 Oct 2026

Stored, listed, copyable, and deliberately unrunnable here. There is no server-side runner in this lab, so a PHP snippet is a thing you read and take away, not a thing you preview.

.php

<?php

function celsiusToFahrenheit(float $celsius): float
{
    return $celsius * 9 / 5 + 32;
}

foreach ([0, 20, 37] as $degrees) {
    printf("%s°C is %s°F\n", $degrees, round(celsiusToFahrenheit($degrees), 1));
}
There is no Run button for PHP Saved, listed and copyable. PHP needs a server-side runner, which this lab does not have, so there is no Run button. Copy it and run it where a PHP interpreter lives. There is no PHP pane in the sandbox either, so this has no Run button and no way to open it in an editor: the lab stores this code, lists it, and shows it as text.
Enter your credentials to continue to your workspace.
Email address
Remember me
Don't have an account? Sign up
Enter your details below to create your account
Name
Email address
Password
Confirm password
Already have an account? Log in
Enter your email and we will send you a reset link
Email address
Or, return to log in