Return value
Return value คือ ผลลัพธ์ที่ฟังก์ชันส่งกลับไปให้กับส่วนที่เรียกใช้ฟังก์ชันนั้น
Example
<?php
function add($x, $y) {
return $x + $y;
}
$result = add(5, 10);
echo $result; // Output: 15
?>public class Main {
public static int add(int x, int y) {
return x + y;
}
public static void main(String[] args) {
int result = add(5, 10);
System.out.println(result); // Output: 15
}
}#include <stdio.h>
int add(int x, int y) {
return x + y;
}
int main() {
int result = add(5, 10);
printf("%d", result); // Output: 15
return 0;
}ข้อดี/ข้อเสีย
วิธีใช้เรียกใช้
สรุป
#Reference
Last updated