simple question about OO in PHP
Posted: Wed Aug 12, 2009 2:55 am
Hello everyone,
I'm new to PHP and used to code in Java. I tried the following but get a parser error for the "public $bla =..." line. X_Debug tells me: "Syntax Error: Expected: identifier, +, -". What is wrong?
Interestingly, I don't get an error message if I move the line beyond the class definition.
I'm new to PHP and used to code in Java. I tried the following but get a parser error for the "public $bla =..." line. X_Debug tells me: "Syntax Error: Expected: identifier, +, -". What is wrong?
Interestingly, I don't get an error message if I move the line beyond the class definition.
Code: Select all
class Coordinate2D
{
public $x = 0;
public $y = 0;
}
class Paper
{
// paper dimension
const WIDTH_MM = 380;
const HEIGHT_MM = 290;
// 1 point = 2.83465669 mm
const MM_PER_POINT = 2.83465669;
public $bla = new Coordinate2D;
}