Re: [PHP] Re: OOP Newbie - why does this not work?
Andy Pieters wrote: While the use of () or not doesn't impede the function of his code, I consider it good programming habit to always add () to the class creator. Since it is creator? you mean constructor (same difference). considered a function, you wouldn't call a function like x=function but 'method' would be more 'correct'. and I don't agree that it is considered a function as you are not directly calling the constructor (if it even exists), but rather instantiating an instance of a class. but that is all rather purist, and not really in the spirit of php. regardless you cant write ... :-) class Test {} $x = new (Test); although you can do the following (for the benefit of the OP): class Test {} $a = b; $b = Test; $c = a; $d = ( ${${$c}} ); /* (the brackets are optional) */ $x = new $d;/* or: $x = $d(); */ $y = new ${(b)}; /* or: $y = new ${(b)}(); */ $z = new ${${$c}}; /* or: $z = new ${${$c}}(); */ ${} = new Test; var_dump($x, $y, $z, ${}); rather x=function(). It is more consistent that way. Consistency shares a house with Standards, and you know what they say about Stan ;-) On Friday 21 October 2005 16:31, Jochem Maas wrote: Nathan Tobik wrote: You have to show us the definition for your class, also your syntax for new is wrong. It should be: $liveclass = new Test(); it can also be (if you have nothing to pass to the constructor function): $liveclass = new Test; Nate Tobik (412)661-5700 x206 VigilantMinds -Original Message- From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] Sent: Friday, October 21, 2005 7:57 AM To: php-general@lists.php.net Subject: [PHP] Re: OOP Newbie - why does this not work? Here,s my guess: var $liveclass; $liveclass = new(Test); echo $liveclass-get() ; echo BR ; echo This is in the php code block ; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: OOP Newbie - why does this not work?
Here,s my guess: var $liveclass; $liveclass = new(Test); echo $liveclass-get() ; echo BR ; echo This is in the php code block ; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: OOP Newbie - why does this not work?
You have to show us the definition for your class, also your syntax for new is wrong. It should be: $liveclass = new Test(); Nate Tobik (412)661-5700 x206 VigilantMinds -Original Message- From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] Sent: Friday, October 21, 2005 7:57 AM To: php-general@lists.php.net Subject: [PHP] Re: OOP Newbie - why does this not work? Here,s my guess: var $liveclass; $liveclass = new(Test); echo $liveclass-get() ; echo BR ; echo This is in the php code block ; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: OOP Newbie - why does this not work?
Nathan Tobik wrote: You have to show us the definition for your class, also your syntax for new is wrong. It should be: $liveclass = new Test(); it can also be (if you have nothing to pass to the constructor function): $liveclass = new Test; Nate Tobik (412)661-5700 x206 VigilantMinds -Original Message- From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] Sent: Friday, October 21, 2005 7:57 AM To: php-general@lists.php.net Subject: [PHP] Re: OOP Newbie - why does this not work? Here,s my guess: var $liveclass; $liveclass = new(Test); echo $liveclass-get() ; echo BR ; echo This is in the php code block ; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: OOP Newbie - why does this not work?
While the use of () or not doesn't impede the function of his code, I consider it good programming habit to always add () to the class creator. Since it is considered a function, you wouldn't call a function like x=function but rather x=function(). It is more consistent that way. On Friday 21 October 2005 16:31, Jochem Maas wrote: Nathan Tobik wrote: You have to show us the definition for your class, also your syntax for new is wrong. It should be: $liveclass = new Test(); it can also be (if you have nothing to pass to the constructor function): $liveclass = new Test; Nate Tobik (412)661-5700 x206 VigilantMinds -Original Message- From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] Sent: Friday, October 21, 2005 7:57 AM To: php-general@lists.php.net Subject: [PHP] Re: OOP Newbie - why does this not work? Here,s my guess: var $liveclass; $liveclass = new(Test); echo $liveclass-get() ; echo BR ; echo This is in the php code block ; -- Now listening to on amaroK Geek code: www.vlaamse-kern.com/geek Registered Linux User No 379093 If life was for sale, what would be its price? www.vlaamse-kern.com/sas/ for free php utilities -- pgpd6AH5Ivt4b.pgp Description: PGP signature