MVC / OO events system

-1

I'm writing my first PHP application. From what I've been studying, I've chosen to learn Object Orientation and MVC.

I am building this application following a book I have, and it is returning the following error:

Parse error: syntax error, unexpected 'private' (T_PRIVATE) in C:\wamp\www\denis-manzetti\sys\class\class.calendar.inc.php on line 11

sys / core /
init.inc.php

sys / config db-cred.inc.php
class.event.inc.php

sys / class class.event.inc.php
class.db_connect.inc.php
class.calendar.inc.php
public / index.php

If anyone can quote what I should study, thank you in advance, hugs

    
asked by anonymous 21.05.2015 / 09:14

1 answer

3

You are setting a public attribute and within this attribute, you are setting another attribute that is private , this can not happen, you can not define an attribute for a function and within it create another function with another attribute . I do not know how it is in your book, but this usually generates this error, what you can do is create a function without attributes, of type function , if you are inside a function that already has an assignment. You can see the compilation in ideone :

link // Code that generates error

link // Code that does not generate the error

But the correct method of doing this your algorithm is to separate the _loadEventData from the constructor method, and call it through the $this operator by doing the following:

class Calendar{
    private $_useDate;
    private $_m;
    private $_y;
    private $_daysInMonth;
    private $_startDay;

    private function _loadEventData($id=NULL)
    {
       //codigo
    }

    public function __construct($dbo=NULL, $_useDate=NULL)
    {
        $this->_loadEventData();
        //codigo
    }

}
    
21.05.2015 / 09:55