« PHP 8.3 Manual トップ
著作権 »
per page, with , order by , clip by
Results of 1 - 1 of about 1 for getHtml (0.001 sec.)
オブジェクト インターフェイス | PHP 8.3 9414
オブジェクト インターフェイス オブジェクト インターフェイスでは、クラスが実装すべきメソッドやプロパティの 宣言だけを行うコードを作成できます。ここでは具体的な実装は必要ありません。 インターフェイスはクラス、トレイト、列挙型と名前空間を共有す ... インターフェイス 'Template' を宣言する interface Template { public function setVariable ( $name , $var ); public function getHtml ( $template ); } // インターフェイスを実装する。 // これは動作します。 class WorkingTemplate implements Template { private ... $vars = []; public function setVariable ( $name , $var ) { $this -> vars [ $name ] = $var ; } public function getHtml ( $template ) { foreach( $this -> vars as $name => $value ) { $template = str_replace ( '{' . $name . '}' , $value , $temp ... ません。 // Fatal error: Class BadTemplate contains 1 abstract methods // and must therefore be declared abstract (Template::getHtml) class BadTemplate implements Template { private $vars = []; public function setVariable ( $name , $var ) { $this -> vars ...
https://man.mtool.work/php/8.3/language.oop5.interfaces.html
PREV 1 NEXT