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.

 

Link to comment
Share on other sites

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']);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.