728x90
728x90
type
-
PHP parameter 및 return 지정법PHP 2020. 12. 11. 15:34
interface 를 사용해서 parameter 및 return 지정법을 알아보자 interface 를 생성해보자 interface ContractInterface { public function compare(string $str1, string $str2):bool; } parameter 의 타입은 java 와 동일하게 작성해주면 된다 return 타입은 함수 뒤에 작성해 주면된다 이 interface 를 구현하는 클래스를 작성해보자 class Concreate implements ContractInterface { public function compare(string $str1, string $str2):bool { if($str1 === $str2) { return true; } else { r..