01.php Object Oriented

Source: Internet
Author: User

Here is some basic knowledge of php_oop

1<?PHP
echo "<meta charset= ' utf-8 ' >"//Set Chinese output2    Header("Content-type:text/html;charset=utf-8"); Set Chinese output3 //1. Building Object-oriented classes:4    classcomputer{5      Public $_name;//a field of a class that can be assigned or not assigned at the time of declaration6      Public $_modle= ' I7 ';7      Public function_run () {//methods of the class8        Echo‘Object-oriented learning ';9 }Ten } One //2. Instantiating an object (an object can be instantiated multiple times and instantiated once is equivalent to creating a separate memory area) A $com 1 = new computer (); - $com 2 = new computer (); -3. Output the value of the $_modle in computer (the ' $ ' variable is not used here) the echo $com 1->_modle; - echo $com 2->_modle; - //4. Assigning values to variables of an object -$com 1->_name = ' Lenovo '; +$com 2->_name = ' Dell '; - //5. Method of Execution + $com 1, _run (); A?>

01.php Object Oriented

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.