П О Р Т А Л                            
С Е Т Е В Ы Х                          
П Р О Е К Т О В                        
  
                                                 
Главная

О проекте

Web-мастеру
     HTML & JavaScript
     SSI
     Perl
     PHP
     XML & XSLT
     Unix Shell

MySQL

Безопасность

Хостинг

Другое







Самое читаемое:

Учебник PHP - "Для Чайника".
Просмотров 91869 раз(а).

Иллюстрированный самоучитель по созданию сайтов.
Просмотров 28165 раз(а).

Учебник HTML.
Просмотров 54686 раз(а).

Руководство по PHP5.
Просмотров 25084 раз(а).

Хостинг через призму DNS.
Просмотров 29347 раз(а).

Подборка текстов стандартных документов.
Просмотров 28115 раз(а).

Учебник PHP - Самоучитель
Просмотров 32398 раз(а).

Документация на MySQL (учебник & справочное руководство)
Просмотров 34107 раз(а).

Внешние атаки...
Просмотров 26108 раз(а).

Учебник PHP.
Просмотров 22009 раз(а).

SSI в примерах.
Просмотров 17307 раз(а).



 
 



Руководство по PHP
Пред. Глава 16. Control Structures След.

Alternative syntax for control structures

PHP offers an alternative syntax for some of its control structures; namely, if, while, for, foreach, and switch. In each case, the basic form of the alternate syntax is to change the opening brace to a colon (:) and the closing brace to endif;, endwhile;, endfor;, endforeach;, or endswitch;, respectively.

<?php if ($a == 5): ?>
A is equal to 5
<?php endif; ?>

In the above example, the HTML block "A is equal to 5" is nested within an if statement written in the alternative syntax. The HTML block would be displayed only if $a is equal to 5.

The alternative syntax applies to else and elseif as well. The following is an if structure with elseif and else in the alternative format:

<?php
if ($a == 5):
    echo
"a equals 5";
    echo
"...";
elseif (
$a == 6):
    echo
"a equals 6";
    echo
"!!!";
else:
    echo
"a is neither 5 nor 6";
endif;
?>

See also while, for, and if for further examples.



 





Copyright © 2005-2011 Project.Net.Ru