bapi Posted May 19, 2007 Share Posted May 19, 2007 Hi, I am new to OOP and got the bitter tast right now. i created two class let name be class A and Class B. Class B - has a method with variable class B{ function something($var1, Var2) { ............... } } Now i used this class in class A class A{ function nextthing(){ A::something($var1, Var2) ..................................... } } Now i get error message "Undifine $var1 & $var2" when i run it thru other file, How can i solve this problem. Quote Link to comment https://forums.phpfreaks.com/topic/52119-unable-to-carry-avriable-from-one-class-to-other/ Share on other sites More sharing options...
maxim Posted May 19, 2007 Share Posted May 19, 2007 maby in your parent class use a accessor method ie (set and get method) to set your data members. and then extend the parent class with a subclass. and access them through the subclass which would extend the patent class through inheritance. now you could set up a constructor in you parent class to set your data members OR just invoke your methods to set them so they can be accessed. failing that maby read up on OOP more in depth Quote Link to comment https://forums.phpfreaks.com/topic/52119-unable-to-carry-avriable-from-one-class-to-other/#findComment-257113 Share on other sites More sharing options...
448191 Posted May 20, 2007 Share Posted May 20, 2007 You should post your actual code. If this resembles your actual code, it is not surprising you are getting errors. Also, when posting OOP questions, it helps if you tell people what version you're on. Quote Link to comment https://forums.phpfreaks.com/topic/52119-unable-to-carry-avriable-from-one-class-to-other/#findComment-257384 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.