Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

Keyword endif

Close the complete colon-style conditional, including any elseif and else branches.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

if ($condition): /* branch */ endif;

Close the complete colon-style conditional, including any elseif and else branches. Each branch begins with a colon and the single endif ends the whole chain. Do not mix braces and alternative syntax within that control structure.

$n=0;
if($n<0): echo "minus"; elseif($n===0): echo "zero"; else: echo "plus"; endif;
zero

Examples

<?php
$n=0;
if($n<0): echo "minus"; elseif($n===0): echo "zero"; else: echo "plus"; endif;

Result

zero

Sources