Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php conditionals

#Conditionals

<?php
    #Conditionals
    /*
    == equals
    === identical
    < less than
    > greater than
    <= less than or equal to
    >= greate than or equal to
    != not equal to
    !== not identrical
    */
    $num = 5;

    #if($num == 5){
     #   echo '5 passed';
    #}elseif($num == 6){
   #     echo '6 passed';
  #  }else{
 #       echo'did not pass';
#    }

    #nesting If Statements
    
    if($num>4){
        if($num < 10){
            echo "$num passed<br>";
        }
    }
    /*
    Logical operators can be used 
    instead of what is above

    and     &&
    or      ||
    xor          means one has to be true but not both
    */
    if($num >4 && $num <10){
        echo "$num passed using Logical operators";
    }
    /*
    Switch tests for value and then find
    a match and do something
    */
    $favColor = 'pink';

    switch($favColor){
    case 'red':
        echo '<br>Your favorite color is red';
        break;
    case 'green':
        echo '<br>OH NO!! Your favorite color is green';
        break;
    case 'blue':
        echo '<br>Kool!! Your favorite color is blue';
        break;
    default:
        echo '<br>Yikes! Your favorite color is something else';
        
    }

?>
Comment

PREVIOUS NEXT
Code Example
Php :: how to download file from s3 bucket using php 
Php :: smarty switch case 
Php :: enable extensions in php.ini 
Php :: php key_exists 
Php :: laravel sharing image 
Php :: carbon if date is today 
Php :: woocommerce update_status 
Php :: laravel create many to many table 
Php :: laravel function 
Php :: saving an image from pc to php 
Php :: The specified module could not be found php 
Php :: php <= 
Php :: php list all files in directory 
Php :: where clause in laravel 
Php :: convert collection to array laravel 
Php :: laravel belongstomany prevent duplicates attach 
Php :: PHP: How to remove specific element from an array? 
Php :: PHP $argv echo 
Php :: laravel PageController.php 
Php :: laravel validation custom message example 
Php :: php get duplicate keys in array without using inbuilt function 
Php :: laravel model where in 
Php :: how to check if query is successfully inserted laravel 
Php :: language_attributes for wordpress 
Php :: laravel eloquent multiple join 
Php :: auto reload for laravel 
Php :: git reset head 3 . how to back git init 
Php :: Woocommerce Changing the Entry Title of the Custom Endpoint 
Php :: php huruf besar di awal 
Php :: wp wc php edit archive-product category page 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =