PHP 지연 정적 바 인 딩 사용 방법 인 스 턴 스 분석
코드 목록 5-11 예상 치 못 한 계승
<?php
 class ParentBase {
  static $property = 'Parent Value';
  public static function render() {
   return self::$property;
  }
 }
 class Descendant extends ParentBase {
  static $property = 'Descendant Value';
 }
 echo Descendant::render();
 Parent Value지연 정적 바 인 딩 기능 을 도입 하여 static 역할 도 메 인 키워드 접근 류 의 속성 이나 방법의 최종 값 을 사용 할 수 있 습 니 다.예 를 들 어 코드 와 같 습 니 다.
 <?php
 class ParentBase {
  static $property = 'Parent Value';
  public static function render() {
   return static::$property;
  }
} 
 class Descendant extends ParentBase {
  static $property = 'Descendant Value';
 }
 echo Descendant::render();
 Descendant Valueget 사용called_class()방법
 <?php
 class ParentBase {
  public static function render() {
   return get_called_class();
  }
 }
 class Decendant extends ParentBase {}
 echo Descendant::render(); 
 Descendant이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Laravel - 변환된 유효성 검사 규칙으로 API 요청 제공동적 콘텐츠를 위해 API를 통해 Laravel CMS에 연결하는 모바일 앱(또는 웹사이트) 구축을 고려하십시오. 이제 앱은 CMS에서 번역된 콘텐츠를 받을 것으로 예상되는 다국어 앱이 될 수 있습니다. 일반적으로 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.