Home >Backend Development >PHP Problem >Is php an object-oriented language?

Is php an object-oriented language?

(*-*)浩
(*-*)浩Original
2019-09-18 10:30:233559browse

In the use of PHP language, you can use process-oriented and object-oriented respectively, and you can mix PHP process-oriented and object-oriented together, which is something that many other programming languages ​​cannot do.

Is php an object-oriented language?

In object-oriented programming (English: Object-oriented programming, abbreviation: OOP), an object is a collection of information and the processing of information The processing description as a whole is an abstraction of the real world.

The main three characteristics of objects: (Recommended learning: PHP programming from entry to proficiency)

The behavior of objects: can be imposed on objects Those operations, turning on the lights and turning off the lights are behaviors.

The shape of the object: how the object responds, color, size, and appearance when those methods are applied.

Representation of objects: The representation of objects is equivalent to an ID card. It specifically distinguishes the differences between the same behaviors and states.

PHP class definition

The usual syntax format of PHP definition class is as follows:

<?php
class phpClass {
  var $var1;
  var $var2 = "constant string";
  
  function myfunc ($arg1, $arg2) {
     [..]
  }
  [..]
}
?>

The analysis is as follows:

A class is defined using the class keyword followed by the class name.

Variables and methods can be defined within a pair of braces ({}) after the class name.

Variables of the class are declared using var, and variables can also be initialized.

Function definition is similar to the definition of PHP function, but the function can only be accessed through the class and its instantiated objects.

The above is the detailed content of Is php an object-oriented language?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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