<?php
interface SlugifierInterface
{
/**
* Return a URL safe version of a string.
*
* @param string $string
* @return string
*/
public function slugify($string);
}
class Sluggifier implements SlugifierInterface
{
public function __construct()
{
}
/*
public function slugify($string)
{
return "I am from" . $string;
}
*/
public function slugify($string)
{
return "I am from static " . $string;
}
}
echo Sluggifier::slugify("Hello World") . "\n";
$sluggifier = new Sluggifier();
echo $sluggifier->slugify("Hello World from object") . "\n";
Fatal error: Uncaught Error: Non-static method Sluggifier::slugify() cannot be called statically in /in/j0mHe:30
Stack trace:
#0 {main}
thrown in /in/j0mHe on line 30
Process exited with code 255.
Deprecated: Non-static method Sluggifier::slugify() should not be called statically in /in/j0mHe on line 30
I am from static Hello World
I am from static Hello World from object
Output for 7.3.32 - 7.3.33, 7.4.26
I am from static Hello World
I am from static Hello World from object
Strict Standards: Non-static method Sluggifier::slugify() should not be called statically in /in/j0mHe on line 30
I am from static Hello World
I am from static Hello World from object
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/j0mHe on line 2
Process exited with code 255.