免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1706 | 回复: 4
打印 上一主题 下一主题

php中的有:运算符吗? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-02-08 18:03 |只看该作者 |倒序浏览


  1. if ( !in_array('Snoopy', get_declared_classes() ) ) :
  2. ....
  3. endif;
复制代码


表示什么意思,好像跟?:表达式不同??!!

另外,谁知道__()函数是怎么使用的,跟普通函数一样?有版本限制?
谢谢

[ 本帖最后由 swingcoder 于 2006-2-8 18:04 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2006-02-08 22:55 |只看该作者
这应该是表达式的不同的表示方法吧,不是很常用,比如:


  1. if (a==1):
  2.     //something
  3. endif;
复制代码


详见:http://www.php.net/manual/en/control-structures.alternative-syntax.php

论坛徽章:
0
3 [报告]
发表于 2006-02-09 08:23 |只看该作者
in_array('Snoopy', get_declared_classes() )中
get_declared_classes()返回以定义的类(数组)
in_array函数检查第一个参数是否在第二个参数(数组)中,成功返回真

__xxxxx()为php类的预定义方法,由于没有出现在手册的函数列表中,你需要通过手册中的“搜索”功能找到他们

论坛徽章:
0
4 [报告]
发表于 2006-02-09 09:07 |只看该作者
原帖由 dz902 于 2006-2-8 22:55 发表
这应该是表达式的不同的表示方法吧,不是很常用,比如:


  1. if (a==1):
  2.     //something
  3. endif;
复制代码


详见:http://www.php.net/manual/en/control-structures.alternative-syntax.php


奇怪,今天怎么上不了php.net

论坛徽章:
0
5 [报告]
发表于 2006-02-09 09:42 |只看该作者
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.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP