thesilvester Posted March 23, 2008 Share Posted March 23, 2008 Can someone please show me how to pass arguments when I create a new object. Quote Link to comment Share on other sites More sharing options...
Sparda Posted March 23, 2008 Share Posted March 23, 2008 class MyClass { function _constructor($a) { $b = $a; echo $b; } } $classInst = new MyClass("Food"); Some thing like that? Quote Link to comment Share on other sites More sharing options...
jollyrancher82 Posted March 23, 2008 Share Posted March 23, 2008 The PHP constructor is called __construct(). Sparda has the right idea you can pass parameters to the constructor when you create the object. Quote Link to comment 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.