Here is the code for my class:
<?php
include ('Special.php');
class SpecialContainer
{
private $dataArray;
public function _construct()
{
$this->dataArray = array();
echo"Created new Location instance<br/>";
}
public function addSpecialItem($Special_Item)
{
array_push($this->dataArray, $Special_Item);
}
}
?>
Its throwing an error at the following line in another php file:
$SpecialContainerObj->addSpecialItem($SpecialObj);
The error is this:
Warning: array_push() [function.array-push]: First argument should be an array in /home/**********s/SpecialContainer.php on line 16
..
Im confused, could someone clarify please how I can resolve this. Thanks
public function _construct()
There is a missing underscore. You should also notice, that your message is never echo
d
public function __construct()
However, you should define something like this directly within the class declaration
class Foo {
private $dataArray = array();
// Other code
}