" symbol after new comes out, with codes such as "$a ->index();"."/> " symbol after new comes out, with codes such as "$a ->index();".">
Home >Backend Development >PHP Problem >php method of calling object
php Call the method of the object
php Call and introduce the object
Directly go to the instance :
Definition:
<?php namespace app\php; class a { static $q = 888; public function index() { echo "1111"; } static function debug() { echo "<br/>"; echo 555; } }
Usage:
<?php namespace app\php; include "./a.php"; class b { public function b() { echo 111; } } $b = new b(); $b ->b(); $a = new a(); $a ->index(); echo $a::$q; $a::debug();
In PHP, for object properties (non-static) and methods (non-static), use "new" after coming out -> "This is consistent with access. Unlike other languages, use "." directly after new to access.
To access static data, use the "::" symbol to access it.
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of php method of calling object. For more information, please follow other related articles on the PHP Chinese website!