Home >Backend Development >PHP Problem >What is the php initialization method?

What is the php initialization method?

coldplay.xixi
coldplay.xixiOriginal
2020-09-30 10:32:294224browse

php initialization method: Use the constructor construct to implement, the code is [public function __construct($count,$money){$this->count = $count;$this->money = $money; }].

What is the php initialization method?

php initialization method:

Use the constructor construct to achieve

<?php
class Saler{
public function __construct($count,$money){  #初始化方法
$this->count = $count;
$this->money = $money;
}
}
$s1 = new Saler(100,100);
$s2 = new Saler(1000,1000);
$s1->__construct(1000,1000);
var_dump($s1,$s2);

Think To learn more about programming learning, please pay attention to the php training column!

The above is the detailed content of What is the php initialization method?. 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