Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Codecademy;
- // Basic function for true or false condition
- function truthyOrFalsy($val){
- if ($val){
- return "True";
- } else {
- return "False";
- }
- }
- echo truthyOrFalsy(2);
- echo "\n\n";
- echo truthyOrFalsy(null);
- // using readable 'or' 'and' operators
- $is_admin = FALSE;
- $is_user = TRUE;
- if ($is_admin or $is_user){ //can also use ||
- echo "You can change the password.\n";
- }
- $correct_pin = TRUE;
- $sufficient_funds = TRUE;
- if ($correct_pin and $sufficient_funds){ // or use &&
- echo "You can make the withdrawal.";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement