Jump to content

Newbie Object Oriented programming question


sakibd2k

Recommended Posts

 

Hi all,

I am very new in OOP in PHP.

Here i want to do

There is two class define in two seperate php pages.What i want to do i want to use one property under one object  to another page(which is another different class). To do that

 

Class Rate{

  var $ discharge = 0 //(i initialize it);

var $ rateinitial = 0;

--------------------------------

there is lot of function in the middle which is not required.

-----------------------------

 

  function rate_engine(&--,--,--){

$kkkkkkk=round(abs($this->rat_obj[$m][12]));

 

//i did the following thing over here property of currnet object get this value at this time and use it to  //another page another object

 

$this->discharge=$kkkkkkk;

 

  }

}

and now there is another page another class

 

class B2A{

 

function(---------------){

 

$m= $m + $rate->discharge;(my point is over here adding the property value of another object in another page)

}

 

}

 

but if i do this, my script does not run.

without  thinking of my code i wrote can any one tell what should be done for this kind of thing?

help is appreciated.

Mushfiq.

 

Bit hard to understand you but i'm guessing that you are trying to use an object of class Rate in class B2A.

If you need to keep the rate object persistent then store it in a session.

session_start();

$rate = new Rate();
$_SESSION['rate'] = $rate;

 

Then on whatever page you create an instance of B2A you can pass the rate object in to one of its internal methods or even the constructor.

 

session_start();
$obj = new B2A();
$obj->doSomething($_SESSION['rate']);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.