कंप्यूटर प्रोग्रामिंग/सबरूटीन्स/पीएचपी

subroutines.php सम्पादन

<?php

// This program asks the user for a Fahrenheit temperature,
// converts the given temperature to Celsius,
// and displays the results.

function get_f()
{
    echo "Enter Fahrenheit temperature:\n";
    $f = readline();
        
    return $f;
}

function calculate_c($f)
{
    $c = ($f - 32) * 5 / 9;
        
    return $c;
}

function display_result($f, $c)
{
    echo $f . "° Fahrenheit is " . $c . "° Celsius";
}

function main()
{
    $f = get_f();
    $c = calculate_c($f);
    display_result($f, $c);
}

main();

?>

कोशिश करो सम्पादन

निम्न कोड मुफ्त ऑनलाइन विकास के वातावरण में से एक में ऊपर कॉपी और पेस्ट करो या अपने खुद के कम्पाइलर/इंटरप्रेटर/आईडीई का उपयोग करें।

यह भी देखें सम्पादन