I'm brand new to OOP and I'm trying to figure out how to create an if statement in a class but am getting the following error:
Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /home/.../class.Dog.php on line 13
Here is my code:
...
$obj = new dog();
$obj->determine_sex();
...
<?php
class dog {
var $name = "Bailey";
var $gender = "boy";
function eat_snake() {
$statement="Your dog, $this->name, ate the snake!";
return $statement;
}
function determine_sex() {
if $this->gender == "boy" {
echo "HE IS A BOY!<br>"; }
}
}
?>
Yes, weird example but just trying to learn here.
Thanks for your help in advance.