当前位置: 编程技术>php
本页文章导读:
▪php 云标签的简单范例 php 云标签的例子,代码如下:
<?php
/**
* @php 云标签
* @param $tags 标签列表
* @edit:www.
*/
function printTagCloud($tags) {
// $tags is the array
arsort($tags);
$max_size = 32; // max font size in pixel.........
▪php 上传图片的函数示例 1,form表单部分
<!-- Form Area -->
<form enctype="multipart/form-data" action="/blog_article/uploader.html" method="post">
Select Image: <input type="file" name="userfile">
<input type="submit" value="Upload!">
</form>
&l.........
▪php 获取站点描述信息的代码 php获取meta站点信息的方法,代码如下:
<?php
/**
* @get_meta_tags函数的应用实例
* @获取站点描述信息
* @edit:www.
*
*/
// Header...
header("Content-Type: text/html; charset=utf-8");
// Function Starts Here..........
[1]php 云标签的简单范例
来源: 互联网 发布时间: 2013-12-24
php 云标签的例子,代码如下:
<?php /** * @php 云标签 * @param $tags 标签列表 * @edit:www. */ function printTagCloud($tags) { // $tags is the array arsort($tags); $max_size = 32; // max font size in pixels $min_size = 12; // min font size in pixels // largest and smallest array values $max_qty = max(array_values($tags)); $min_qty = min(array_values($tags)); // find the range of values $spread = $max_qty - $min_qty; if ($spread == 0) { // we don't want to divide by zero $spread = 1; } // set the font-size increment $step = ($max_size - $min_size) / ($spread); // loop through the tag array foreach ($tags as $key => $value) { // calculate font-size // find the $value in excess of $min_qty // multiply by the font-size increment ($size) // and add the $min_size set above $size = round($min_size + (($value - $min_qty) * $step)); echo '<a href="#" . $size . 'px" title="' . $value . ' things tagged with ' . $key . '">' . $key . '</a> '; } } //调用示例 $tags = array('weddings' => 32, 'birthdays' => 41, 'landscapes' => 62, 'ham' => 51, 'chicken' => 23, 'food' => 91, 'turkey' => 47, 'windows' => 82, 'apple' => 27); printTagCloud($tags); ?>
[2]php 上传图片的函数示例
来源: 互联网 发布时间: 2013-12-24
1,form表单部分
<!-- Form Area --> <form enctype="multipart/form-data" action="/blog_article/uploader.html" method="post"> Select Image: <input type="file" name="userfile"> <input type="submit" value="Upload!"> </form> <!-- Form Area -->
2,上传图片文件的php代码
<?php # Variables $path = "images/"; $max_size = "200000"; # File $filename = $_POST['userfile']; # Control if (!isset($HTTP_POST_FILES['userfile'])) exit; if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) { if ($HTTP_POST_FILES['userfile']['size']>$max_size) { echo "文件太大,超过了上传文件的最大限制。The Max File Size is $max_size KB<br>n"; exit; } # Type Control if ( ($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/jpg") || ($HTTP_POST_FILES['userfile']['type']=="image/bmp") || ($HTTP_POST_FILES['userfile']['type']=="image/png") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") ) { # If File Exist if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { echo "同名的文件已存在。<br>"; exit; } $res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path . $HTTP_POST_FILES['userfile']['name']); if (!$res){ echo "上传失败!<br>"; exit; } else{ echo "上传成功!<br>"; } echo "File Name: ".$HTTP_POST_FILES['userfile']['name']."<br>"; echo "File Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>"; echo "File Type: ".$HTTP_POST_FILES['userfile']['type']."<br>"; echo "<a href=/blog_article/$path/index.html".$HTTP_POST_FILES['userfile']['name'].">View Image</a>"; } else { echo "错误的文件类型<br>"; exit; } } ?>
注意:
在php5以后的代码,已经不再使用这样的方式,改用全局变量$_FILE来接收上传数据了。
[3]php 获取站点描述信息的代码
来源: 互联网 发布时间: 2013-12-24
php获取meta站点信息的方法,代码如下:
<?php /** * @get_meta_tags函数的应用实例 * @获取站点描述信息 * @edit:www. * */ // Header... header("Content-Type: text/html; charset=utf-8"); // Function Starts Here... function getInfo($URL){ $getInfo= get_meta_tags($URL); return $getInfo; } // URL... $URL = "http://www."; $_getInfo = getInfo($URL); // Print. echo "$URL <p>"; echo $_getInfo ["author"]."<p>"; echo $_getInfo ["keywords"]."<p>"; echo $_getInfo ["description"]."<p>"; echo $_getInfo ["robots"]."<p>"; ?>
最新技术文章: