Hi Im new to PHP and trying to implement a class. Inside the class one of my variables is an array. Basically, what I am confused about is how do I initialize the array and then add an element to it using a function. This is the code I have so far but Im getting a syntax error message in the IDE.
<?php
class Food
{
var $foodName = "";
var $foodCals = "";
var $foodDesc = "";
var $foodPrice = "";
var $numSides = "";
$sidesArray = array();
function addSide($sideItem)
{
array_push($sidesArray, "$sideItem");
}
}
?>
Get a syntax error that says:
Syntax error: unexpected: $sidesArray expected: function, const, var, }, static, abstract, final, private, protected, public
What am I doing wrong? Thanks.