• 회원가입
  • 로그인
  • 구글아이디로 로그인

[PHP-생코] PHP 6강 - 생성자 (인스턴스 초기화) ★★★

767  

생성자 : 인스턴스 생성 시 수행할 기본 작업을 정의한 메서드.

 

<?php

// 클래스

class MyFileObject{

  function __construct($fname){

    $this->filename = $fname;

  }

  function isFile(){

    return is_file($this->filename);

  }

}

// 인스턴스

$file = new MyFileObject('data.txt');

// $file->filename = 'data.txt';

var_dump($file->isFile());

var_dump($file->filename);

 

https://www.php.net/manual/en/language.oop5.decon.php

https://opentutorials.org/module/6/15729

 

PS.

 

Constructor (생성자) : __construct()함수

https://homzzang.com/b/php-1063

 

 

 


분류 제목
게시물이 없습니다.
목록
찾아주셔서 감사합니다. Since 2012