Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   PHP, PERL, MySQL, JavaScript (https://forum.antichat.xyz/forumdisplay.php?f=37)
-   -   ООП. Метод. Call to undefined function GetFilePerm() ...? (https://forum.antichat.xyz/showthread.php?t=208318)

DonKihot 01.06.2010 09:50

ООП. Метод. Call to undefined function GetFilePerm() ...?
 
Есть метод (функция) ?
Цитата:

public function GetFilePerm($f_name)
{
$this->perms = fileperms($f_name);

if (($this->perms & 0xC000) == 0xC000) {$this->info = 's'; /*socket*/ }
elseif (($this->perms & 0xA000) == 0xA000) {$this->info = 'l'; /*Symboliy link*/}
elseif (($this->perms & 0x8000) == 0x8000) {$this->info = '-'; /*Normal*/ }
elseif (($this->perms & 0x6000) == 0x6000) {$this->info = 'b'; /*Special block*/}
elseif (($this->perms & 0x4000) == 0x4000) {$this->info = 'd'; /*directory */}
elseif (($this->perms & 0x2000) == 0x2000) {$this->info = 'c'; /*Special symbol*/}
elseif (($this->perms & 0x1000) == 0x1000) {$this->info = 'p'; /* FIFO*/}
else {$this->info = 'u'; /* unknow */}

// user
$this->info .= (($this->perms & 0x0100) ? 'r' : '-');
$this->info .= (($this->perms & 0x0080) ? 'w' : '-');
$this->info .= (($this->perms & 0x0040) ?
(($this->perms & 0x0800) ? 's' : 'x' ) :
(($this->perms & 0x0800) ? 'S' : '-'));

// group
$this->info .= (($this->perms & 0x0020) ? 'r' : '-');
$this->info .= (($this->perms & 0x0010) ? 'w' : '-');
$this->info .= (($perms & 0x0008) ?
(($this->perms & 0x0400) ? 's' : 'x' ):
(($this->perms & 0x0400) ? 'S' : '-'));

// world
$this->info .= (($this->perms & 0x0004) ? 'r' : '-');
$this->info .= (($this->perms & 0x0002) ? 'w' : '-');
$this->info .= (($this->perms & 0x0001) ?
(($this->perms & 0x0200) ? 't' : 'x' ):
(($this->perms & 0x0200) ? 'T' : '-'));

return $this->info;
}
Вызываю так :
echo GetFilePerm($this->f_name)
Выдает :
Цитата:

Fatal error: Call to undefined function GetFilePerm() in ...........
Но если поместить этот код в функцию и разместить его в простом коде (не в ООП классе), то все работает..
Получается что то с синтаксисом не в порядке?

GreenBear 01.06.2010 10:46

echo $this->GetFilePerm($this->f_name)
Цитата:

public function GetFilePerm($f_name)
лучше бы так:
Цитата:

public function GetFilePerm($f_name = '')
{
if(!$f_fname) $f_name = $this->f_name;
...
}
echo $this->GetFilePerm()

m0Hze 01.06.2010 12:18

Наверно, снчала нужно создать ваш класс, для дальнейшей работы с ним.
PHP код:

class youclass{
function 
GetFilePerms(){....}
}
$class = new youclass;
echo 
$class->getFilePerm(); 

А если вы используете метод внутри класса, то вызывать нужно $this->Methodname();


Время: 08:29