/out-class-inheritance.php Secret
Created
January 22, 2014 20:34
Star
You must be signed in to star a gist
This gist is a companion to my "Lies, Damn Lies, and PHP Benchmarks" and is the source of some of the benchmarks used.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class AbstractOutput | |
{ | |
abstract public function output (); | |
} | |
class Outputter extends AbstractOutput | |
{ | |
public function output () | |
{ | |
return 'Hello, world!'; | |
} | |
} | |
?><!doctype html> | |
<html> | |
<head> | |
<title>PHP Bench</title> | |
</head> | |
<body> | |
<p><?php $output = new Outputter; echo $output->output(); ?></p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface OutputInterface | |
{ | |
public function output (); | |
} | |
abstract class AbstractOutput implements OutputInterface | |
{ | |
public function output () | |
{ | |
return 'Hello, world!'; | |
} | |
} | |
class Outputter extends AbstractOutput | |
{ | |
} | |
?><!doctype html> | |
<html> | |
<head> | |
<title>PHP Bench</title> | |
</head> | |
<body> | |
<p><?php $output = new Outputter; echo $output->output(); ?></p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface OutputInterface | |
{ | |
public function output (); | |
} | |
class Output implements OutputInterface | |
{ | |
public function output () | |
{ | |
return 'Hello, world!'; | |
} | |
} | |
?><!doctype html> | |
<html> | |
<head> | |
<title>PHP Bench</title> | |
</head> | |
<body> | |
<p><?php $output = new Output; echo $output->output(); ?></p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Outputter | |
{ | |
public static function output () | |
{ | |
return 'Hello, world!'; | |
} | |
} | |
?><!doctype html> | |
<html> | |
<head> | |
<title>PHP Bench</title> | |
</head> | |
<body> | |
<p><?php echo Outputter::output(); ?></p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Outputter | |
{ | |
public function output () | |
{ | |
return 'Hello, world!'; | |
} | |
} | |
?><!doctype html> | |
<html> | |
<head> | |
<title>PHP Bench</title> | |
</head> | |
<body> | |
<p><?php $output = new Outputter; echo $output->output(); ?></p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function output () | |
{ | |
return 'Hello, world!'; | |
} | |
?><!doctype html> | |
<html> | |
<head> | |
<title>PHP Bench</title> | |
</head> | |
<body> | |
<p><?php echo output(); ?></p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment