Basic questions: PHP class definition and calling this post was last edited by bulls5988 at 15:35:23 on
A class is defined in sub. php, which contains a function. Because the returned value must be converted to XML, it cannot be output directly in the function. The following error message is displayed when you call test. php during testing:
Catchable fatal error: Object of class massage_gether cocould not be converted to string in \ xampp \ htdocs \ asxmt_wx \ test. php on line 26
Which of the following steps does I have a problem with the output and call of the class definition?
Sub. php code class massage_gether {function main_menu_test () {// Main menu content $ mytext = 'Welcome to the public service platform of the main store. Please select the number of services you need :'. "\ n ". '(1) Membership card points query '. "\ n ". '(2) shopping mall activity query '. "\ n ". '(4) other services '. "\ n ". 'enter @ to return to the main menu '; return $ mytext ;}}
Index. php code include ("sub. php"); $ shower = new massage_gether (); $ shower-> main_menu_test (); echo $ shower; // This is 26th rows
Reply to discussion (solution)
$ Shower = new massage_gether ();
Echo $ shower-> main_menu_test ();
$ Shower is an instantiated object.
I have been taught. thank you!