Home > Backend Development > PHP Tutorial > PHP learning diary 1 ----Object-oriented basics

PHP learning diary 1 ----Object-oriented basics

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 08:56:40
Original
921 people have browsed it

php syntax is very similar to c++;

A simple object-oriented code:

                                                                                                                                                                                                                        object-oriented object-oriented code Public $CatAge ;

                                                                                                                                                                                    ; ->CatName = $name;
                                                                                                                                                              $color;
                                                                                                                   "n" represents a space
                        return "{$this->CatName}n"."{$this->CatColor}n"."{$this->CatAge}"; = new Cat("lex","black","3");

//If you assign a value to an attribute that the object does not have, php will not report an error;

$SmallCat ->Wrong = "error;


print "{$SmallCat->ShowCat()}";
?>

print is used to output all items; there is no difference between "" and '' in

php; methods in

php are public by default Type; the attribute defaults to private type


If it meets the grammatical specifications in php, it will not report an error, so checking errors in php is a very troublesome thing;

The above introduces PHP learning diary 1 - object-oriented basics, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template