Code: Select all
function getFileSize($fileName = $this->fileName){
if (file_exists($fileName)){
return filesize($fileName);
}else{
trigger_error("File does not exist!!!", E_USER_WARNING);
return FALSE;
}
}Moderator: General Moderators
Code: Select all
function getFileSize($fileName = $this->fileName){
if (file_exists($fileName)){
return filesize($fileName);
}else{
trigger_error("File does not exist!!!", E_USER_WARNING);
return FALSE;
}
}This is the standard way to acheive it....raghavan20 wrote:I have a function for which I want to set the default value of the parameter to a class variable...but it gives error...is there is any alternative to it...Code: Select all
function getFileSize($fileName = $this->fileName){ if (file_exists($fileName)){ return filesize($fileName); }else{ trigger_error("File does not exist!!!", E_USER_WARNING); return FALSE; } }
Code: Select all
<?php
function getFileSize($fileName = false){
if ($fileName === false) $fileName = $this->fileName;
if (file_exists($fileName)){
return filesize($fileName);
}else{
trigger_error("File does not exist!!!", E_USER_WARNING);
return FALSE;
}
}
?>