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 adds an image in web page?
<div> <img> <span>
<img src="http://coursesweb.net/imgs/webcourses.gif" width="191" height="63" alt="Courses-Web" />
Which of these CSS codes displays the text oblique?
font-style: italic; text-decoration: underline; font-weight: 500;
#id {
  font-style: italic;
}
Click on the jQuery function used to hide with animation a HTML element.
click() hide() show()
$(document).ready(function() {
  $(".a_class").click(function(){ $(this).hide("slow"); });
});
Click on the correctly defined function in PHP.
fname function() {} function fname() {} function $fname() {};
function fname($a, $b) {
  echo $a * $b;
}
Chaining Static and Public Methods in PHP

Last accessed pages

  1. Atlantis Quest (2324)
  2. Flash Chess 3 (1221)
  3. CSS Course - Free lessons (7382)
  4. Backgammon (3846)
  5. Galactic Gems 2 Level Pack (736)

Top accessed pages

  1. Courses Web: PHP-MySQL JavaScript Ajax HTML CSS Flash-AS3 (50836)
  2. Read Excel file data in PHP - PhpExcelReader (39650)
  3. PHP-MySQL free course, online tutorials PHP MySQL code (37875)
  4. Get Attribute (ID, Class, Name, Title, Src) with jQuery (34149)
  5. PHP PDO - exec (INSERT, UPDATE, DELETE) MySQL (31628)