PHP readline() 함수 실습 방법? command 모드에서 값 입력받는 방법?
본문
<?php
function classify_board($length, $width, $material) {
if ($length > 8 && $width > 8) {
if ($material == 'wood') {
return 'longboard';
} elseif ($material == 'plastic') {
return 'cruiser';
}
} elseif ($length <= 8 && $width <= 8) {
if ($material == 'wood') {
return 'skateboard';
} elseif ($material == 'plastic') {
return 'mini-cruiser';
}
} else {
return 'unknown';
}
}
$board_length = (int) readline("Enter the length of the board in inches: ");
$board_width = (int) readline("Enter the width of the board in inches: ");
$board_material = readline("Enter the material of the board (wood or plastic): ");
$board_category = classify_board($board_length, $board_width, $board_material);
echo "The board is a: " . $board_category . "\n";
chatGPT가 위와 같은 코드를 짜줬는데, 위 예제를 어떻게 실습해야할지 모르겠어요,
command 모드에서 값을 입력받는 것 같은데....
!-->
답변을 작성하시기 전에 로그인 해주세요.