How to use PHP to continuously call functions using chain calls

墨辰丷
Release: 2023-03-30 15:58:02
Original
3051 people have browsed it

This article mainly introduces how to use PHP to continuously call functions using chain calls. Friends who are interested can refer to it. I hope it will be helpful to everyone.

The details are as follows:

<?php
 //返回$this,实现连续调用
 class xin {
  function name($namec) {
    echo "我的名字是:$namec <br/>";
    return $this;
  }
  function age($agec) {
    echo "我的年龄是:$agec <br/>";
    return $this;    
  }
 }
 $xind = new xin();
 $xind->name("星星")->age("10000");
?>
Copy after login

The running results are as follows:

My name is: Xingxing
My age is: 10000

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

Detailed explanation of fuzzy query and association of three select boxes with pictures and text in PHP

PHP How to use Socket to obtain the SSL certificate and public key of the website

Detailed explanation of fuzzy query and association of three select boxes in PHP with pictures and text

The above is the detailed content of How to use PHP to continuously call functions using chain calls. For more information, please follow other related articles on the PHP Chinese website!

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