문제

i'm following a tutorial about OOP on : http://www.phptuts.nl/view/45/8/

But in the following piece of code there seems to be an error on line 2. Since it doesn't seem like it's actually on the second line, it has to be somewhere in the script, am i doing something wrong? (new to this).

Here's the code:

<?php
public function draw() {
    echo '<table border="1">'.PHP_EOL; // Begin van de tabel, border voor de duidelijkheid

    foreach($this->_rows as $row) {
        echo '<tr>'.PHP_EOL;

        foreach($row->getCells() as $cell) {
            echo '<td>'.$cell->getContent().'</td>'.PHP_EOL;
        }

        echo '</tr>'.PHP_EOL;
    }

    echo '</table>'.PHP_EOL;
}
?>
도움이 되었습니까?

해결책

public can only be used in classes. That function is not in a class. Remove it and your error should go away.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top