Saturday, December 1, 2018

if statment

something practical

You can have 'nested' if statements withing a single if statement, using additional parenthesis. 
For example, instead of having: 

<?php if( $a == || $a == ) {
    if( 
$b == || $b == ) {
        if( 
$c == || $ == ) {
             
//Do something here.
        
}
    }
?> 
You could just simply do this: 

<?php if( ($a==|| $a==2) && ($b==|| $b==4) && ($c==|| $c==6) ) {
    
//do that something here. ?> 






You can do IF with this pattern :
<?php
$var 
TRUE;
echo 
$var==TRUE 'TRUE' 'FALSE'// get TRUEecho $var==FALSE 'TRUE' 'FALSE'// get FALSE?>




<?php
// validate alphanumeric 
$input="gfghfhfhgg1223445-5";
if(preg_match('/^[a-zA-Z]+[a-zA-Z0-9-]+$/', $input))
{
    echo "valid statment";
}
else
{
    //invalid
    echo "non valid statment";
}

?>

No comments:

Post a Comment

form validation

function formsubmit ( ) { var empname = document .getElementById ( 'emp_name' ). value ; var email = document .getElem...