something practical
For example, instead of having:
<?php if( $a == 1 || $a == 2 ) {
if( $b == 3 || $b == 4 ) {
if( $c == 5 || $ d == 6 ) {
//Do something here.
}
}
} ?>
You could just simply do this:
<?php if( ($a==1 || $a==2) && ($b==3 || $b==4) && ($c==5 || $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