canViewMovie function - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of canViewMovie function.php
- <?php
- function canViewMovie($age, $balance, $price){
- if ($age >= 18 && $balance >= $price){
- return "Let's view the movie!";
- }
- elseif($age >= 18 && ($balance < $price)){
- return "Damn, better earn some more money.";
- }
- else {
- return "Looks like we're not old enough to get into that movie...";
- }
- }
- $age1 = 18;
- $balance1 = 13;
- $price1 = 10;
- $age2 = 15;
- $balance2 = 50;
- $price2 = 12;
- $age3 = 25;
- $balance3 = 4;
- $price3 = 11;
- echo canViewMovie($age1, $balance1, $price1) . "\n";
- echo canViewMovie($age2, $balance2, $price2) . "\n";
- echo canViewMovie($age3, $balance3, $price3) . "\n";
File Description
- canViewMovie function
- PHP Code
- 24 May-2020
- 630 Bytes
You can Share it:
Latest PHP Pastes