What is the difference between declaring an array using "var" and "public" in PHP?

Declaring an array using "var" makes it a private variable within a class, while using "public" makes it a public variable that can be accessed outside the class. If you want to access the array outside the class, you should declare it as a public variable.

class MyClass {
    public $arrayPublic = array(); // Declaring as a public variable
}

$obj = new MyClass();
$obj->arrayPublic[] = "element1";
print_r($obj->arrayPublic); // Output: Array ( [0] => element1 )