stdClass - A newbie question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello everybody, 


In this class sketch:


<?php

class Pagination {

    ...
      
	public static function Pagination ($total_records, $limit, $page)


	{

	  $total_pages = ceil($total_records / $limit);

        $page = max($page, 1);

        $page = min($page, $total_pages);

        $offset = ($page -1) * $limit;


        
        $pagi_obj= new stdClass;

        $pagi_obj->total_pages = $total_pages;

        $pagi_obj->offset = $offset;

        $pagi_obj->limit = $limit;

        $pagi_obj->page;



        return $pagi_obj;

        

    }  

    
}


Why do the author used a stdClass ?
What are the advantages of using a stdClass?

Since we are already inside a class, why do we need to create a new object
from another class, inside this one? 
Why do we keep the values passed as params on method Pagination inside this
stdClass object, and not inside Pagination own properties for example? 

Any help clarifying this, knowing that I'm a newbie,

Regards,
Márcio


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux