slimboy007 Posted June 21, 2010 Share Posted June 21, 2010 How can i finish the following class to print "Person->name is only human" when the following is executed on a Person object: print $person; class Person{ private $name = ''; public function __construct($name){ $this->name = $name; } } $person = new Person('Andrew'); print $person; // Andrew is only human Link to comment https://forums.phpfreaks.com/topic/205399-adding-more-output-to-a-print/ Share on other sites More sharing options...
phpchamps Posted June 21, 2010 Share Posted June 21, 2010 i am not getting ur question and also the purpose of doing this.. but try this.. class Person{ public $name = ''; public function __construct($name){ $this->name = $name; } } $person = new Person('Andrew'); echo $person->name. " is only human";// Andrew is only human Link to comment https://forums.phpfreaks.com/topic/205399-adding-more-output-to-a-print/#findComment-1074902 Share on other sites More sharing options...
the182guy Posted June 21, 2010 Share Posted June 21, 2010 i am not getting ur question and also the purpose of doing this.. but try this.. It's a homework question, along with his other three threads Link to comment https://forums.phpfreaks.com/topic/205399-adding-more-output-to-a-print/#findComment-1074915 Share on other sites More sharing options...
phpchamps Posted June 21, 2010 Share Posted June 21, 2010 why people come here for homework... huh!!!!! Link to comment https://forums.phpfreaks.com/topic/205399-adding-more-output-to-a-print/#findComment-1074922 Share on other sites More sharing options...
slimboy007 Posted June 21, 2010 Author Share Posted June 21, 2010 doh this is a forum ain't it for help for people who are stuck or just learning php so what does it matter? but thank you for the help appreciate it Link to comment https://forums.phpfreaks.com/topic/205399-adding-more-output-to-a-print/#findComment-1074949 Share on other sites More sharing options...
phpchamps Posted June 21, 2010 Share Posted June 21, 2010 you are not stuck there.. if a person can create a class then he/she should be knowing about appending the text to a variable... right???????? So, instead of taking a code from here and putting it in your assignment.... try to learn it.....ofcourse only if you are looking to be a developer.. otherwise.. keep doing it.. get marks.. but not knowledge.. Link to comment https://forums.phpfreaks.com/topic/205399-adding-more-output-to-a-print/#findComment-1074955 Share on other sites More sharing options...
slimboy007 Posted June 21, 2010 Author Share Posted June 21, 2010 i disagree. not right Link to comment https://forums.phpfreaks.com/topic/205399-adding-more-output-to-a-print/#findComment-1074974 Share on other sites More sharing options...
phpchamps Posted June 21, 2010 Share Posted June 21, 2010 may be not right for you... Link to comment https://forums.phpfreaks.com/topic/205399-adding-more-output-to-a-print/#findComment-1074976 Share on other sites More sharing options...
trq Posted June 21, 2010 Share Posted June 21, 2010 doh this is a forum ain't it for help for people who are stuck or just learning php so what does it matter? but thank you for the help appreciate it Read our TOS. Link to comment https://forums.phpfreaks.com/topic/205399-adding-more-output-to-a-print/#findComment-1074979 Share on other sites More sharing options...
Recommended Posts