Fundamentals
function greet_language(string $lang = "PHP"): string { return "Hello {$lang}!"; }
function greet_language($lang = "PHP") {print "Hello $lang!\n";- function greet_language(string $lang = "PHP"): string
- {
- return "Hello {$lang}!";
- }
greet_language();greet_language("Javascript");greet_language("Ruby");
class MyTestCase extends TestCase { public function testThatSomethingShouldHappen() { $this->assertEquals('Hello Javascript!', greet_language('Javascript')); $this->assertEquals('Hello Ruby!', greet_language('Ruby')); } public function testRandomInputs() { for ($i = 0; $i < 40; $i++) { // make a random name from a random source $name = base64_encode(random_bytes(6)); $this->assertEquals("Hello {$name}!", greet_language($name)); } } }
- class MyTestCase extends TestCase
- {
- public function testThatSomethingShouldHappen()
- {
- $this->assertEquals('Hello Javascript!', greet_language('Javascript'));
- $this->assertEquals('Hello Ruby!', greet_language('Ruby'));
- }
- public function testRandomInputs()
- {
- for ($i = 0; $i < 40; $i++) {
- // make a random name from a random source
- $name = base64_encode(random_bytes(6));
- $this->assertEquals("Hello {$name}!", greet_language($name));
- }
- }
- }