php-windows | 2003112
Date: 11/16/03
- Next message: S F Alim: "RE: [PHP-WIN] Re: GD Lib"
- Previous message: Roy Henderson: "RE: [PHP-WIN] PHP in general"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The first
} should be after the last } for addRow() to be a method.. lol... Like this
(didn't try, but seems correct):
<html>
<head>
<title>A Class with a Constructor</title>
</head>
<body>
<?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();
?>
</body>
</html>
-- // DvDmanDT MSN: dvdmandt€hotmail.com Mail: dvdmandt€telia.com ########################## Please, if you are using windows, you may be infected by Swen. Please go here to find out more: http://us.mcafee.com/virusInfo/default.asp?id=helpCenter&hcName=swen http://securityresponse.symantec.com/avcenter/venc/data/w32.swen.a <email protected> ########################## "Rocco Castoro" <roccoman <email protected>> skrev i meddelandet news:20031116011631.22011.qmail <email protected> > ok, this is gunna be annoying but does anyone know why i get this error: > Fatal error: Call to undefined function: addrow() in C:\Program Files\Apache > Group\Apache2\htdocs\Hour8-7MainExample.php on line 63 when trying to > execute this code: > > <html> > <head> > <title>A Class with a Constructor</title> > </head> > <body> > <?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(); > ?> > </body> > </html> > > thanks > "Rocco Castoro" <roccoman <email protected>> wrote in message > news:20031116011115.15724.qmail <email protected> > > Yes it does, But IM lost in a space full of variables and strings and I > dont > > know what half of them mean, I dont wanna give up but this book SUCKS.... > > "Gaguwd" <larenga2985 <email protected>> wrote in message > > news:PAEKIBPEBDMPALHFKNCKIEGECMAA.larenga2985 <email protected> > > > Wellllllllll, it depends on what you want to make. PHP has almost no > > limits. > > > Since it works with FTP, MySQL and many other external languages, > > protocols > > > and the like, your imagination is the limit. > > > > > > So, it's used for many things. There are blog scripts, guestbooks, > > counters, > > > database managers, portal managers, forum managers, email systems, RPG > > > games, and lots of etc. > > > > > > Hope it helps... > > > > > > Bye! > > > MG29 > > > > > > -----Mensaje original----- > > > De: Rocco CAstoro [mailto:roccoman <email protected>] > > > Enviado el: Sábado, 15 de Noviembre de 2003 09:14 p.m. > > > Para: php-windows <email protected> > > > Asunto: [PHP-WIN] PHP in general > > > > > > > > > I'm learning PHP for reasons I dont know... I just feel that with my > > passion > > > for code and computers, that I will be able to use this information to > > > create great things... I guess my question is, what all is PHP used for > > > anyways? > > > > > > -- > > > PHP Windows Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: S F Alim: "RE: [PHP-WIN] Re: GD Lib"
- Previous message: Roy Henderson: "RE: [PHP-WIN] PHP in general"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

