[tdb_header_logo align_vert="content-vert-center" disable_h1="yes" svg_width="eyJwaG9uZSI6IjMwIn0=" svg_color="#ffffff" show_image="eyJwaG9uZSI6Im5vbmUifQ==" show_tagline="eyJwaG9uZSI6Im5vbmUifQ==" show_title="eyJwaG9uZSI6ImJsb2NrIn0=" show_icon="eyJwaG9uZSI6Im5vbmUifQ==" text="Study Warehouse" f_text_font_size="eyJwaG9uZSI6IjMwIn0=" text_color="#ffffff"]
[tdb_mobile_search icon_color="#ffffff" tdicon="td-icon-search" icon_size="eyJhbGwiOjIyLCJwaG9uZSI6IjIxIn0="][tdb_mobile_menu inline="yes" menu_id="" icon_color="#ffffff" icon_size="eyJhbGwiOjI3LCJwaG9uZSI6IjI5In0=" tdc_css="eyJwaG9uZSI6eyJtYXJnaW4tcmlnaHQiOiItMTYiLCJwYWRkaW5nLXRvcCI6IjIiLCJkaXNwbGF5IjoiIn0sInBob25lX21heF93aWR0aCI6NzY3fQ=="]
[tdb_header_logo align_vert="content-vert-center" svg_color="#ffffff" svg_width="eyJwb3J0cmFpdCI6IjMwIiwiYWxsIjoiMzUifQ==" show_image="none" show_tagline="none" show_title="" show_icon="none" text="Study Warehouse" show_svg="none" f_text_font_size="35" text_color="#ffffff"]
[tdb_header_search inline="yes" toggle_txt_pos="after" form_align="content-horiz-right" results_msg_align="content-horiz-center" image_floated="float_left" image_width="eyJhbGwiOiIxNSIsInBvcnRyYWl0IjoiMTQifQ==" image_size="" show_cat="none" show_btn="none" show_date="none" show_review="none" show_com="none" show_excerpt="none" show_author="none" meta_padding="eyJhbGwiOiIwIDAgMCAxNnB4IiwicG9ydHJhaXQiOiIwIDAgMCAxMnB4In0=" art_title="0" all_modules_space="eyJhbGwiOiIxNiIsInBvcnRyYWl0IjoiMTIifQ==" disable_trigger="yes" exclude_pages="yes" form_bg="rgba(0,0,0,0)" form_padding="0" form_border="0" input_placeholder="Search for Content..." tdc_css="eyJhbGwiOnsibWFyZ2luLXJpZ2h0IjoiNDAiLCJ3aWR0aCI6IjM0MCIsInotaW5kZXgiOiIxMDAwMDAwMDAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0Ijp7Im1hcmdpbi1yaWdodCI6IjMwIiwid2lkdGgiOiIzMDAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" input_bg="var(--violet)" input_border="0" btn_tdicon="td-icon-search" btn_text="" input_padding="eyJhbGwiOiIwIDE0cHggMXB4IiwicG9ydHJhaXQiOiIwIDEwcHgifQ==" btn_padding="eyJhbGwiOiIwIDE0cHgiLCJwb3J0cmFpdCI6IjAgMTBweCJ9" btn_icon_size="eyJhbGwiOiIxOCIsInBvcnRyYWl0IjoiMTYifQ==" btn_bg="rgba(0,0,0,0)" btn_bg_h="rgba(0,0,0,0)" btn_icon_color_h="#ffffff" btn_icon_color="var(--white-transparent)" f_input_font_family="308" f_input_font_size="eyJhbGwiOiIxNCIsInBvcnRyYWl0IjoiMTMifQ==" f_placeholder_font_family="308" f_placeholder_font_size="eyJhbGwiOiIxNCIsInBvcnRyYWl0IjoiMTMifQ==" btn_icon_align="-1" f_input_font_line_height="eyJhbGwiOiIyLjUiLCJwb3J0cmFpdCI6IjIuMiJ9" f_placeholder_font_line_height="eyJhbGwiOiIyLjUiLCJwb3J0cmFpdCI6IjIuMiJ9" input_radius="5" placeholder_color="var(--white-transparent)" input_color="#ffffff" el_class="td-ad-header-search" results_bg="var(--violet-2)" results_border="0" results_msg_bg="var(--violet-2)" results_msg_color="var(--white-transparent)" results_msg_color_h="var(--accent)" title_txt="#ffffff" title_txt_hover="var(--accent)" meta_info_align="center" image_height="100" image_radius="5" f_title_font_family="308" f_title_font_size="eyJhbGwiOiIxNCIsInBvcnRyYWl0IjoiMTMifQ==" f_title_font_line_height="1.5" f_title_font_weight="700" results_msg_border="1px 0 0" results_msg_border_color="var(--sep-dark)" f_results_msg_font_family="308" f_results_msg_font_size="11" results_padding="eyJhbGwiOiIyMCIsInBvcnRyYWl0IjoiMTUifQ==" sec_title_color="var(--white-transparent-2)" f_sec_title_font_family="308" f_sec_title_font_size="eyJhbGwiOiIxMyIsInBvcnRyYWl0IjoiMTIifQ==" sec_title_space="eyJhbGwiOiIxMCIsInBvcnRyYWl0IjoiOCJ9" f_sec_title_font_weight="500" f_sec_title_font_line_height="1.5" results_section_1_level="0" results_section_2_level="0" results_section_3_level="0" tax_title_color="#ffffff" tax_title_color_h="var(--accent)" f_tax_title_font_family="308" f_tax_title_font_size="eyJhbGwiOiIxNSIsInBvcnRyYWl0IjoiMTQifQ==" f_tax_title_font_line_height="1.5" tax_space="eyJwb3J0cmFpdCI6IjQifQ==" show_results=""]
[tdb_header_menu main_sub_tdicon="td-icon-down" sub_tdicon="td-icon-right-arrow" mm_align_horiz="content-horiz-center" modules_on_row_regular="20%" modules_on_row_cats="25%" image_size="td_324x400" modules_category="image" show_excerpt="none" show_com="none" show_date="none" show_author="none" mm_sub_align_horiz="content-horiz-right" mm_elem_align_horiz="content-horiz-right" menu_id="" text_color="var(--white-transparent)" f_elem_font_transform="none" elem_padd="0" elem_space="eyJhbGwiOiI0MCIsInBvcnRyYWl0IjoiMzAifQ==" f_elem_font_line_height="eyJhbGwiOiI2MnB4IiwicG9ydHJhaXQiOiI1MnB4In0=" f_elem_font_family="308" f_elem_font_weight="500" f_elem_font_size="eyJhbGwiOiIxNSIsInBvcnRyYWl0IjoiMTQifQ==" tds_menu_active1-line_width="0" tds_menu_active1-text_color_h="var(--accent)" show_subcat="yes" sub_bg_color="var(--violet-2)" sub_padd="eyJhbGwiOiIxNXB4IDIwcHgiLCJwb3J0cmFpdCI6IjEzcHggMTVweCJ9" sub_elem_padd="0" sub_elem_space="eyJhbGwiOiI2IiwicG9ydHJhaXQiOiI0In0=" sub_text_color="var(--white-transparent-2)" tds_menu_sub_active1-sub_text_color_h="var(--accent)" f_sub_elem_font_family="general_global" f_sub_elem_font_size="eyJhbGwiOiIxNCIsInBvcnRyYWl0IjoiMTMifQ==" f_sub_elem_font_line_height="1.5" sub_first_left="eyJhbGwiOiItMjAiLCJwb3J0cmFpdCI6Ii0xNSJ9" sub_border_radius="5" main_sub_icon_size="eyJhbGwiOiIxMiIsInBvcnRyYWl0IjoiMTAifQ==" main_sub_icon_align="eyJhbGwiOjAsInBvcnRyYWl0IjoiMCJ9" main_sub_icon_space="eyJhbGwiOiI4IiwicG9ydHJhaXQiOiI2In0=" sub_width="eyJhbGwiOiIyMDAiLCJwb3J0cmFpdCI6IjE2MCJ9"]
[tdb_header_menu_favorites tdicon="td-icon-heart-full" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjAiLCJkaXNwbGF5IjoiIn19" icon_color="#ffffff" icon_size="eyJhbGwiOjIxLCJwb3J0cmFpdCI6IjE5In0=" show_count="" count_bg_color="#0020f4" url="https://studywarehouse.com/favorite-applications/"]
Home Blog if Statement in PhP

if Statement in PhP

0
if Statement in PhP

The if Statement is the simplest conditional statements.

In if  Statements Output will appear when only Condition must be true.

If Statement works  much like the English language statement, “if X happens, then do Y.”

Syntax

if (condition) {
    code to be executed if condition is true;
}

In the example below will output “Have a good day!” if the current time (HOUR) is less than 20:

<?php
$t = date("H");

if ($t < "20") {
    echo "Have a good day!";
}
?> 

Example to find the sum of even number between 1 to 100

<?php
$sum=0;
 
for($i=1;$i<=100;$i++)
{
if($i%2==0)
{
$sum=$sum+$i;
}
}
echo $sum;
?>

Output: 2550

LEAVE A REPLY

Please enter your comment!
Please enter your name here