timbrown Posted March 14, 2007 Share Posted March 14, 2007 Hi there, Is there a way of using an include to define a method in a class? Quote Link to comment https://forums.phpfreaks.com/topic/42696-include-a-function-in-a-class-definition/ Share on other sites More sharing options...
per1os Posted March 14, 2007 Share Posted March 14, 2007 Can we an example code of what you are trying to do? --FrosT Quote Link to comment https://forums.phpfreaks.com/topic/42696-include-a-function-in-a-class-definition/#findComment-207148 Share on other sites More sharing options...
timbrown Posted March 14, 2007 Author Share Posted March 14, 2007 ok, you might have a function in an include file like this - thefunction.inc function functionName(){ some code... } and I want to include that function in a class definition as a method like this - class className { public someVar = ""; public someVar = ""; public someVar = ""; // defining a method normally function someFunction(){ some code... } // define one using the include include("thefunction.inc"); } this doesn't work because php is expecting a function, not an include. Quote Link to comment https://forums.phpfreaks.com/topic/42696-include-a-function-in-a-class-definition/#findComment-207173 Share on other sites More sharing options...
per1os Posted March 14, 2007 Share Posted March 14, 2007 Yea, according to what I know it is not possible, why do that anyways? --FrosT Quote Link to comment https://forums.phpfreaks.com/topic/42696-include-a-function-in-a-class-definition/#findComment-207181 Share on other sites More sharing options...
timbrown Posted March 14, 2007 Author Share Posted March 14, 2007 just so my various classes can share function code. Quote Link to comment https://forums.phpfreaks.com/topic/42696-include-a-function-in-a-class-definition/#findComment-207211 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.