-
PHP 8 에서 인수 앞에 매개변수 이름을 넣을 수 있다
만일 지정인수가 없다면
function( 3 , 5, 0 , 19 );
와 같이 매개변수에 값을 넣지 않는 부분에도 0 을 꼭 넣어줘야한다
하지만 지정인수를 설정하면 순서에 상관없이 매개변수를 이용할 수 있다
public function calulate($cost , $quantity, $discount = 0 , $tax = 0){ }
위와같이 함수가 선언되었다면,
calulate(5 , 10 , tax : 3); 또는 calulate(quantity : 7 , cost : 4 , tax : 10 )
원하는 방법대로 함수를 호출할 수 있다
'php' 카테고리의 다른 글
Class .. Static (0) 2023.09.06 Class (0) 2023.09.06 엄격한 타입 활성화 (0) 2023.09.04 전역 / 정적 / 옵셔널 변수 (0) 2023.09.04 워드프레스 페이지 추가 (0) 2023.09.01