Re: PHP CODE ERROR?
| From: | Bob Harris | Date: | Mon, 17 Nov 2003 12:16:15 +0000 |
| Subject: | Re: PHP CODE ERROR? | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-22122@lists.php.net to get a copy of this message | ||
Could it be related to the fact the none of the functions being called as
"$test->func_call()" are actually defined as being a member of your class
"Table"?
Thus addrow() might exist but $test->addrow() does not.
"B.A.T. Svensson" <B.A.T.Svensson@lumc.nl> wrote in message
news:D291F33C586C8E48B95C26F8C805513A319C71@mail5.lumc.nl...
> http://www.php.net/manual/en/language.oop.php
>
> -----Original Message-----
> From: Rocco CAstoro
> To: php-windows@lists.php.net
> Sent: 16-11-2003 6:58
> Subject: [PHP-WIN] PHP CODE ERROR?
>
> Can Anyone tell my why this error is produced:
>
> Fatal error: Call to undefined function: addrow() in C:\Program
> Files\Apache\Group\Apache2\htdocs\Hour8-7MainExample.php on line 63
>
> From this code:
>
> <?php
>
> // Defining the Class's Properties -------
> class Table
> {
> var $table_array = array();
> var $headers = array();
> var $cols;
> }
>
> //Creating a Constructor ------
> function Table( $headers )
> {
> $this->headers = $headers;
> $this->cols = count ( $headers );
> }
>
> //The addROw() Method ------
> function addRow( $row )
> {
> if ( count ($row) != $this->cols )
> return false;
> array_push($this->table_array, $row);
> return true;
> }
>
> //The addRowAssocArray() Method
> function addRowAssocArray( $row_assoc )
> {
> $row = array();
> foreach ( $this->headers as $header )
> {
> if ( ! isset( $row_assoc[$header] ))
> $row_assoc[$header] = "";
> $row[] = $row_assoc[$header];
> }
> array_push($this->table_array, $row);
> return true;
> }
>
> //
> function output()
> {
> print "<pre>";
> foreach ( $this->headers as $header )
> print "<B>$header</B> ";
> print "\n";
> foreach ( $this->table_array as $y )
> {
> foreach ( $y as $xcell )
> print "$xcell ";
> print "\n";
> }
> print "</pre>";
> }
>
> $test = new table( array("a", "b", "c") );
> $test->addRow( array(1,2,3) );
> $test->addRow( array(4,5,6) );
> $test->addRowAssocArray (array ( b=>0, a=>6, c=>3 ) );
> $test->output();
> ?>
>
> Thanks Alot guys your MUCHos HHelpos
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php