質問

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