If you want to see the result here - print_r($result->getAllData()); then you need to return the result:
function getAllData() { array_push($this->array, 'no_enter_data'); return $this->array; }
If you want to get at __destruct , then here is a little different.
The destructor is called, but the result of its work is not displayed, therefore return meaningless. It is necessary then so:
class X { function __construct() { $this->array = array(); } function __destruct() { print_r($this->array); } function getAllData() { array_push($this->array, 'no_enter_data'); } } $result = new X; $result->getAllData();
PS It is worth considering that the destructor is called when the class is destroyed. Usually - at the end of the entire script.
returnin thegetAllDatamethodgetAllDatanot forgotten? - Suvitruf ♦