Skip to main content

fungsi dari public

May 24, 2010 by annura

annura's picture

teman2 mau nanya neh :
function() {

}

public function() {

}

nah yang mau saya tanyakan neh. fungsi dari public itu untuk apa ya?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

sebagai pembeda hak akses di

September 13, 2010 by enss, 1 year 20 weeks ago
Comment: 7107

enss's picture

sebagai pembeda hak akses di dlm class..
contoh:

class test{
public function pub(){
echo "public";
}
private function pri(){
echo "private";
}
protected function pro(){
echo "protected";
}
function tes(){
echo "test";
}
}
$coba= new test;
$coba->pub(); // mencetak "public"
$coba->pri(); // fatal error, karena method nya private
$coba->pro(); // sama fatal error jg
$coba->tes(); // mencetak "test"

klo kita nulis "function tes()" sama az artinya dengan "public function tes()"

hope it helps ^^

Sebaiknya anda membaca php

August 28, 2010 by mul14, 1 year 23 weeks ago
Comment: 7076

mul14's picture

Sebaiknya anda membaca php manual untuk mengerti public yang digunakan dalam class. http://id.php.net/public

Premium Drupal Themes by Adaptivethemes