Could you help me? I want to see what is wrong with this program-php Tutorial

Source: Internet
Author: User
Could you tell me what is wrong with this program? I have created a user class, which has four private attributes: "Name", "student ID", "age", and "contact number, the constructor must assign values to the attribute "name" and assign values and access to other attributes through methods. Print the user information of "Michael", "200440132", "21", and "63886666. & Lt ;? PhpclassMessage {private $ name; could you tell me something wrong with this program?
Create a user class that has four private attributes: "Name", "student ID", "age", and "contact number". you must assign a value to the "name" attribute through the constructor, other attributes are also assigned and accessed through methods. Print the user information of "Michael", "200440132", "21", and "63886666.
Class Message
{
Private $ name;
Private $ num;
Private $ age;
Private $ tel;

Function _ construct ($ name, $ num, $ age, $ tel)
{
$ This-> name = $ name;
$ This-> num = $ num;
$ This-> age = $ age;
$ This-> tel = $ tel;
}
Function say ()
{
Echo "User:" $ this-> name"
Student ID: "$ this-> num"
Age: "$ this-> age"
Contact number: "$ this-> tel;
}
$ P = new Message ("zhang san", 20010000132,21, 63886666 );
$ P-> say ();
?>

------ Solution --------------------
PHP code
Function say () {echo "User:". $ this-> name ."
Student ID: ". $ this-> num ."
Age: ". $ this-> age ."
Contact number :". $ this-> tel; // The serial number is useless here} // the serial number is not closed, with less braces $ p = new Message ("zhang san", 20010000132,21, 63886666 );
------ Solution --------------------
Echo "User:". $ this-> name ."
Student ID: ". $ this-> num ."
Age: ". $ this-> age ."
Contact number: ". $ this-> tel;

Note connector
------ Solution --------------------
PHP code
    Name = $ name; $ this-> num = $ num; $ this-> age = $ age; $ this-> tel = $ tel;} function say () {echo "User :". $ this-> name."
Student ID: ". $ this-> num ."
Age: ". $ this-> age ."
Contact number :". $ this-> tel; // variable and string connector .}} // write less.} $ p = new Message ("zhang san", 20010000132,21, 63886666); $ p-> say ();?>
------ Solution --------------------
Thank you for not ending the post for half a day.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.