To chain a static and a public method through class name, for example:
className::staticMethod()->publicMethod()
The instance of the className must be returned in the staticMethod, using "return new self" .
- Code example:
<?php
class clsShow {
  public static $url;

  public static function setData(){
    self::$url = 'https://coursesweb.net/';
    return new self;
  }

  public function show(){
    echo self::$url;
  }
}

// accessing show() method after setData()
clsShow::setData()->show();             // https://coursesweb.net/

• To this page: PHP Method Chaining it is a lesson with more details and examples about chaining multiple methods.

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag create a highlighted bolded text?
<q> <strong> <em>
<p>Address: <strong>http://CoursesWeb.net/</strong> - Tutorials.</p>
Which of these CSS codes displays the text bolded?
text-size: 18px; font-style: italic; font-weight: 800;
#id {
  font-weight: 800;
}
What JavaScript function can be used to call another function multiple times, to a specified time interval?
setInterval() setTimeout() push()
function someFunction() { alert("CoursesWeb.net"); }
setInterval("someFunction()", 2000);
Click on the correctly defined variable in PHP.
var vname = 8; $vname = 8; $vname == 8;
$vname = 8;
echo $vname;
Chaining Static and Public Methods in PHP

Last accessed pages

  1. Functions, Variable scope and Passing by Reference (1460)
  2. Node.js Move and Copy Directory (818)
  3. PhpSpreadsheet - Read, Write Excel and LibreOffice Calc files (7386)
  4. The Mastery of Love (3338)
  5. addChild and removeChild (4565)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Ajax HTML CSS Flash-AS3 (1332)
  2. Qwop (670)
  3. Theme Hotel (590)
  4. Read Excel file data in PHP - PhpExcelReader (519)
  5. Register and show online users and visitors (479)