Ben böyle bir sınıf var Diyelim
class book {
public $title;
public $author;
public $page_num;
.....
....
public function show_book($limit=1){
....
$result = mysql_query("SELECT title,author,page_num FROM book limit=$limit");
while($row = mysql_fetch_array($result))
{
$this->title=$row['title'];
$this->author=$row['author'];
$this->page_num=$row['page_num'];
}
}
ve sonra ben gibi kullanabilirsiniz:
$book = new book();
$book->show_book();
echo $book->title." ".$book->author ...... ;
this works for one book
what if i want to show 7 books ?
this is not working for $book->show_book($limit=7);
i can make 7 objects but i think there's a better way