Laravel for Beginners – Learn to Build Full-Stack Web Apps

Loading video...

Coding Challenge

Problem

Create Route which accepts two route parameters. These parameters should be integers. You should calculate the sum of these two parameters and print that sum.

Solution

Route::get('/sum/{a}/{b}', function(float $a, float $b) {
	echo "Sum: " . ($a + $b);
})
	->whereNumber(['a', 'b'])
;

Discussion

Sign in to join the discussion.

No comments yet. Be the first to start the discussion!