Write a PHP program to compute the sum of the two given integer values. If the two values are the same, then returns triple their sum

  • برمجة بي اتش بي

Write a PHP program to compute the sum of the two given integer values. If the two values are the same, then returns triple their sum

الأجوبة

<?php
function test($x, $y) 
{
    return $x == $y ? ($x + $y)*3 : $x + $y;
}
echo test(1, 2)."\n";
echo test(3, 2)."\n";
echo test(2, 2)."\n";  
 Sample Output:
3
5
12
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...