php GetImageSize
array getimagesize(string filename)
该函数返回一个四无素的矩阵、告诉你所给文件名的图像尺
寸。该文件的格式必须是GIF,jpeg或PNG中的任一种。
元
素
描述
0
宽度的像素数
1
高
度的像素数
2
图像的类型(GIF=1,JPG=2,PNG=3)
3
在
IMG标记中可用的字符串,如"height=# width=#"
例如:
<?php
$image_file = "test.jpg";
$image_info
= getimagesize($image_file);
print("<img src=\"$image_file\"
$image_info[3]>\n");
?>
相关文档:
循环语句
在您编写代码时,您经常需要让相同的代码块运行很多次。您可以在代码中使用循环语句来完成这个任务。
在 PHP 中,我们可以使用下列循环语句:
while
只要指定的条件成立,则循环执行代码块
do...while
首先执行一次代码块,然后在指定的条件成立时重复这个循环
for
循环执行代码块指定的次数
foreach
根 ......
function handleEach(&$array,$functionName)
{
foreach($array as $k=>$v)
{
if(is_array($v))
{
handleEach(&$array[$k],$functionName);
}
else
$array[$k] = $functionName($v);
return $array[$k];
}
} ......
首先注意版本问题,一定要仔细查看php manual上的内容,如http://www.php.net/manual/en/install.windows.apache2.php 上有一个note:
Note
:
Apache 2.2 Support
Users of Apache 2.2 should note that the DLL file for Apache 2.2 is
named php5apache2_2.dll
rather than php5apache2.d ......
0、用单引号代替双引号来包含字符串,这样做会更快一些。因为PHP会在双引号包围的字符串中搜寻变量,单引号则不会,注意:只有echo能这么做,它是一种可以把多个字符串当作参数的“函数”(译注:PHP手册中说echo是语言结构,不是真正的函数,故把函数加上了双引号)。
1、如果能将类的方法定义成static,就尽量 ......
首先注意版本问题,一定要仔细查看php manual上的内容,如http://www.php.net/manual/en/install.windows.apache2.php 上有一个note:
Note
:
Apache 2.2 Support
Users of Apache 2.2 should note that the DLL file for Apache 2.2 is
named php5apache2_2.dll
rather than php5apache2.d ......