PHP if-else-endif Statements
来源:互联网 发布:马航mh370真相 知乎 编辑:程序博客网 时间:2024/06/16 06:55
PHP: if
A typical web developer knows exactly how a PHP if statement looks like:
HTML mess with PHP
When it comes to merge PHP and HTML the things are becoming ugly. Indeed most of the template systems as Smarty are improved and developed to overcome this issue, however when working with a native PHP code with no template system or with template system where the PHP code is allowed the things are really bad.
Let me show this in a breve example. Image you have to show different formatted HTML depending on a PHP expression. Something like that
Now you can see how difficult to maintain this code is when it doesn’t make use of only one code of HTML markup. Imaging you’ve to print differently formatted tables! Indeed the PHP curly brackets are different to follow.
PHP: the different IF syntax
So there is a PHP syntax that tries to help you manage this. You can write more human readable code like this:
Thus you get the ENDIF instead of only one curly bracket. That’s indeed readable enough. In fact you can use this syntax with any conditional or loop statement in PHP:
To return in the previous example the code above should be transformed in that:
- PHP if-else-endif Statements
- 关于#IF #ELSE #ENDIF
- #if...#else...#endif
- #ifdef,#else,#if,#endif
- #if, #elif, #else和#endif
- #if, #elif, #else, #endif 使用
- #if #else #endif 的应用
- #if, #elif, #else, #endif 使用
- #ifdef #else #endif #if #ifndef
- 关于#ifdef,#else,#endif,#if
- #if, #elif, #else, #endif 使用
- #ifdef(#ifndef), #if, #else, #endif
- #if, #elif, #else, #endif 使用
- #if, #elif, #else, #endif 使用
- #if, #elif, #else, #endif 使用
- #if, #elif, #else, #endif 使用
- #if, #elif, #else, #endif 使用
- #if, #elif, #else, #endif 使用
- Personal:RenameFiles
- 关于Java中的default访问权限问题
- NOIP2016蚯蚓
- CentOS解决apue.h错误
- Android Studio中隐藏状态栏和标题栏的方法
- PHP if-else-endif Statements
- springmvc后台获取图片,到jsp页面显示
- FreeCodeCamp学习--Repeat a string repeat a string
- Android Things物联网开发--实战之部署app到开发板(八)
- html标签
- 2 月 4 日星期六
- phpstrom10.0.0.2 mac 汉化记录
- No.7简单操作系统的开发
- 欢迎使用CSDN-markdown编辑器