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

  public static function setData(){
    self::$url = '';
    return new self;

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

// accessing show() method after setData()
clsShow::setData()->show();             //

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

Daily Test with Code Example

Click on the HTML tag which creates an horizontal line in web page.
<br /> <em> <hr />
Some content ...
<hr />
Content under line ...
Which CSS property defines the text color?
font-style font-variant color
h2 {
  color: #cbdafb;
Click on the function which searches if a character, or text exists in a string.
indexOf() toString() split()
var str = "Web courses -";
if(str.indexOf("http://") == -1) alert("http:// isn`t in string");
else alert("http:// is in string");
Which function splits a string into an array of strings based on a separator?
array_merge() explode() implode()
$str = "apple,banana,melon,pear";
$arr = explode(",", $str);
var_export($arr);      // array (0=>"apple", 1=>"banana", 2=>"melon", 3=>"pear")
Chaining Static and Public Methods in PHP

Last accessed pages

  1. Upload Script for Gallery of Images and Audio files (7806)
  2. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (98509)
  3. PhpSpreadsheet - Read, Write Excel and LibreOffice Calc files (19140)
  4. Voting Poll System script PHP-AJAX (6520)
  5. Disable button and Enable it after specified time (8431)

Popular pages this month

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