Skip to content

Instantly share code, notes, and snippets.

@nurtext
Last active December 26, 2015 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nurtext/7080962 to your computer and use it in GitHub Desktop.
Save nurtext/7080962 to your computer and use it in GitHub Desktop.
Shorthand return values without variable assignment
<?php
// Example class
class Hello
{
// Just a simple function wich returns a string
public function World($name = 'World')
{
return sprintf("Hello %s\n", $name);
}
}
// Common example using an assignment
$hello = new Hello();
echo $hello->World();
// Shorthand return value without assignment
echo (new Hello)->World();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment