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 can be used to create input text field in web page?
<form> <input> <div>
<input type="text" name="a_name" value="val" />
Which CSS property displays the text in a small-caps font?
display font-variant font-style
h3 {
  font-variant: small-caps;
}
What instruction displays a notice box with a message inside it, in JavaScript?
for() Date() alert()
var msg = "Visit CoursesWeb.net";
alert(msg);
Indicate the PHP code used to get the users IP.
$_SERVER["HTTP_USER_AGENT"] $_SERVER["REMOTE_ADDR"] $_GET[]
$ip = $_SERVER["REMOTE_ADDR"];
echo $ip;
Chaining Static and Public Methods in PHP

Last accessed pages

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (104423)
  2. Get and Modify content of an Iframe (21558)
  3. Simple Ajax-PHP Contact Form Script (419)
  4. Creating objects in ActionScript (8520)
  5. Contact page - CoursesWeb (45447)

Popular pages this month

  1. Making DIV Contents Scroll Horizontally, with multiple Div`s inside (2315)
  2. Contact page - CoursesWeb (2222)
  3. Tabs effect with CSS (2210)
  4. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (969)
  5. PHP-MySQL free course, online tutorials PHP MySQL code (566)