SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Oop

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Oop

    I have a shopping cart that is written oldschool (procedural) style PHP and I am trying to convert it to OOP PHP and learning as I go. Anyone interested in giving me a few pointers?

    For example:

    Code:
    <?php
    
    class Pagination {
    
    	var $numrows;
    	var $rowsperpage;
    	var $totalpages;
    
            function SetPagination () {
    
    	$this->numrows = 50;
            $this->rowsperpage = 12;   
            $this->totalpages = ceil($this->numrows / $this->rowsperpage); 
       }
    
    }
    
    ?>
    Code:
    <?php
    	 $page = new Pagination();
    	 $page->SetPagination();
    
    	 echo "numrows: " . $page->numrows . "<br />";
             echo "rowsperpage: " . $page->rowsperpage . "<br />";
    	 echo "totalrows: " . $page->totalrows;
        ?>
    why does $totalrows echo null?
    Last edited by berliner_kindl; Apr 30, 2009 at 21:38.

  2. #2
    SitePoint Addict skunkbad's Avatar
    Join Date
    Apr 2008
    Location
    Temecula, CA
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I learned php oop from the book :

    PHP 5 Advanced: Visual QuickPro Guide (Paperback)
    by Larry Ullman

    Very awesome book, and Larry has a forum where he is very active if you have questions.

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    totalrows doesn't exist.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •