易截截图软件、单文件、免安装、纯绿色、仅160KB

PHP数组的使用和遍历

 1、数组的申请和使用:
$array=array(array(2,324,34)); 
echo   $array[0][1]; 
直接申请使用:
$student[0][0]="我";
$student[0][1]="是";
$student[1][0]="谁";
$student[1][1]="维";
 echo   $student[1][0];
2、遍历:
foreach()是一个用来遍历数组中数据的最简单有效的方法。
 
<?php
$colors = array('red','blue','green','yellow');
foreach ($colors as $color) {
echo "Do you like $color? <br />";
}
?>
 
显示结果:
Do you like red?
Do you like blue?
Do you like green?
Do you like yellow?
 
 
 
2. while()
while() 通常和 list(),each()配合使用。
#example2:
 
<?php
$colors = array('red','blue','green','yellow');

while(list($key,$val) = each($colors)) {
echo "Other list of $val.<br />";
}
?>
显示结果:
Other list of red.
Other list of blue.
Other list of green.
Other list of yellow.
 
 
 
3. for()
#example3:
 
<?php
$arr = array ("0" => "zero","1" => "one","2" => "two");

for ($i = 0;$i < count($arr); $i++) {
$str = $arr[$i];
echo "the number is $str.<br />";
}
?>
显示结果:
the number is zero.
the number is one.
the number is two.
 
 
 
========= 以下是函数介绍 ==========
key()
mixed key(array input_array)
key()函数返回input_array中位于当前指针位置的键元素。
#example4
下载: list_array04.php
 
<?php
$capitals = array("Ohio" => "Columbus","Towa" => "Des Moines","Arizona" => "Phoenix");
echo "<p>Can you name the capitals of these states?</p>";
while($key = key($capitals)) {
echo $key."<br />";
next($capitals);
//每个key()调用不会推进指针。为此要使用next()函数
}
?>
显示结果:
Can you name the capitals of these


相关文档:

php:global变量的使用

global定义一个全局变量,这个全局变量不是应用整个网站,而是应用与当前页面(包括require和include文件)文件。
$aa="test";
function test()
{
    global $aa;
    echo $aa;
}
test(); //print test
函数内定义的变量函数外可以调用,在函数外定义的的变量函数内不能使用。
gl ......

php 通过include方式实现国际化多语言(i18n)

include实现国际化
将index.php进行翻译:
Index内容
1.         Index
2.         About us
我们可以将index.php设置为一个翻译模版,所有出现字符的地方,都定义为变量,如1,2部分设置为翻译的变量$menu_index, $menu_aboutus.
......

那些PHP陪我渡过的日子

 无意间看到以前发的帖子.回忆起那些PHP的日日夜夜
http://www.phpfans.net/ask/discuss2/343326196.html
<?
class gzg//钙中钙类
{
        var $x;//属性
        function gzg()//构造函数,默认不吃钙中钙
              &n ......

PHP Security for Deployers

PHP Security for Deployers
If you're a Developer
READ THIS and then work with your SysAdmins to step through any and all the layers of security designed to protect your apps.
Example:
Traffic must first pass through a SPI firewall (ensure that ONLY necessary ports/protocols are permitted; en ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号