class thing { public $lines; function __construct(){ $this->lines = $lines; } function get_lines($file,$chan){ $document = "A:/PHP/logs/".$chan."/".$file.".txt"; if(file_exists($document)){ $info = file_get_contents($document); $ex = explode(" ", $info); $this->lines = $ex["1"]; return $this->lines; } } } $test = new thing(); $test->get_lines("adz","#adz");