php 如何创建一个文件实例代码

创建文件在php中会用到fopen来创建,会用的w或w来创建,所面有关于他的简要说明 fopen函数需要两个重要的信息块正常运行。首先,我们必须提供的文件,我们希望它来打开它命名。第二,我们必须告诉我们什么功能上与该文件做计划

阅读全文

php 给文件尾部增加内容

如果我们想添加到一个文件,我们需要以追加方式打开它。下面的代码了这一点。

If we want to add on to a file we need to open it up in append mode. The code below does just that.

阅读全文

php 文件上传简单实例代码

<?php教程
if($_FILES['file']){
 // ----------------------------------------------------------------------------------------------//
//
// 说明:文件上传   日期:2004-5-2
//
// ----------------------------------------------------------------------------------------------//

阅读全文

PHP中json_encode、json_decode与serialize、unserialize

json_encode和json_decode的效率并没有比serialize和unserialize的效率高,在反序列化的时候性能相差两倍左右,PHP 5.3执行效率比PHP 5.2略有提升。


<?php教程
$target = array (
'name' => '全能头盔',
'quality' => 'Blue',
'ti_id' => 21302,
'is_bind' => 1,
'demand_conditions' =>
array (
'HeroLevel' => 1,
),
'quality_attr_sign' =>
array (
'HeroStrength' => 8,
'HeroAgility' => 8,
'HeroIntelligence' => 8,
),
);
$json = json_encode($target);
$seri = serialize($target);
echo "json : " . strlen($json) . " ";
echo "serialize : " . strlen($seri) . " ";
$stime = microtime(true);
for ($i = 0; $i < 10000; $i ++)
{
json_encode($target);
}
$etime = microtime(true);
echo "json_encode : " . ($etime - $stime) . " ";
//----------------------------------
$stime = microtime(true);
for ($i = 0; $i < 10000; $i ++)
{
json_decode($json);
}
$etime = microtime(true);
echo "json_decode : " . ($etime - $stime) . " ";
//----------------------------------
$stime = microtime(true);
for ($i = 0; $i < 10000; $i ++)
{
serialize($target);
}
$etime = microtime(true);
echo "serialize : " . ($etime - $stime) . " ";
//----------------------------------
$stime = microtime(true);
for ($i = 0; $i < 10000; $i ++)
{
unserialize($seri);
}
$etime = microtime(true);
echo "unserialize : " . ($etime - $stime) . " ";
echo 'DONE.';
?>

阅读全文

php视频网页播放器代码实例

在web开发中经常会碰到一些简单的视频播放功能,但现在的视频格式不同,并且可以动态增加,所以我们就必须把视频保存到数据哦,好了下面我们来看我写的段简单的 php视频网页播放器代码吧。

阅读全文

php mysql留言板代码

本款代码是一款简单的php留言板代码 ,就是把用户提交的数据保存到mysql数据库,判断进行验证用户是否为非法用户,非常简单的比较适合初学者。

阅读全文