2010-12-15 6 views

답변

2

다음은 간단한 예입니다.

<?php 
class HelloWorld { 
var $message = ''; 

function __construct() { 
    $this->message = 'Hello World'; 
} 

function say_hi() { 
    echo $this->message; 
} 
} 
?> 
2

당신은이 모든 방법에있는 당신의 클래스에서 모든 변수에 액세스 할 수 있습니다

$this->myVar; 
0

변수는 클래스 내에서 선언 될 수 있습니다.

<?php 
class ExampleClass { 
public $pub; // accessable anywhere 
protected $pro; // can only be called by this class and classes that extend this class (inherit) 
private $pri; // only accessed by this class 

}?> 

변수 범위는 here

를 설명
관련 문제