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 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. Contact page - CoursesWeb (36864)
  2. Tabs effect with CSS (37501)
  3. Making DIV Contents Scroll Horizontally, with multiple Div`s inside (44470)
  4. Paragraphs, Line break, Horizontal rule (2513)
  5. AJAX Course, free Lessons (9247)

Popular pages this month

  1. Making DIV Contents Scroll Horizontally, with multiple Div`s inside (2422)
  2. Contact page - CoursesWeb (2323)
  3. Tabs effect with CSS (2311)
  4. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (909)
  5. PHP getElementById and getElementsByTagName (860)