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 = 'http://coursesweb.net/';
    return new self;
  }

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

// accessing show() method after setData()
clsShow::setData()->show();             // http://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 renders as emphasized text, displaying the text oblique?
<strong> <pre> <em>
<p>Web development courses: <em>CoursesWeb.net</em></p>
Which CSS property defines the space between the element border and its content?
margin padding position
h3 {
  padding: 2px 0.2em;
}
Click on the method which returns the first element that matches a specified group of selectors.
getElementsByName() querySelector() querySelectorAll()
// gets first Div with class="cls", and shows its content
var elm = document.querySelector("div.cls");
alert(elm.innerHTML);
Indicate the PHP variable that contains data from a form sent with method="post".
$_SESSION $_GET $_POST
if(isset($_POST["field"])) {
  echo $_POST["field"];
}
Chaining Static and Public Methods in PHP

Last accessed pages

  1. The Rise Of Atlantis (7933)
  2. Courses Web: PHP-MySQL JavaScript Ajax HTML CSS Flash-AS3 (54304)
  3. Zuma Deluxe (32813)
  4. Butterfly Kyodai (24554)
  5. SHA512 Encrypt hash in JavaScript (6645)

Popular pages this month

  1. Bubbles3 (2864)
  2. Butterfly Kyodai (2474)
  3. Zuma Deluxe (1770)
  4. Qwop (1183)
  5. Backgammon (1081)