如何测试程序执行到哪里
时间:2010-01-26
来源:互联网
请问一下各位高手,如何测试程序执行到哪里呢?你们平时在研究人家源码的时候在这方面都有哪些技巧呢?我现在在学习ecshop的二次开发,这个东西要看懂确实不容易啊,需要很多调试技巧,不知道各位高手都有和高招,比如 function upload_image($upload, $dir = '', $img_name = '')
{
/* 没有指定目录默认为根目录images */
if (empty($dir))
{
/* 创建当月目录 */
$dir = date('Ym');
$dir = ROOT_PATH . $this->images_dir . '/' . $dir . '/';
}
else
{
/* 创建目录 */
$dir = ROOT_PATH . $this->data_dir . '/' . $dir . '/';
if ($img_name)
{
$img_name = $dir . $img_name; // 将图片定位到正确地址
}
}
/* 如果目标目录不存在,则创建它 */
if (!file_exists($dir))
{
include("lib_base.php");
if (!make_dir($dir))
{
/* 创建目录失败 */
$this->error_msg = sprintf($GLOBALS['_LANG']['directory_readonly'], $dir);
$this->error_no = ERR_DIRECTORY_READONLY;
return false;
}
}
if (empty($img_name))
{
$img_name = $this->unique_name($dir);
$img_name = $dir . $img_name . $this->get_filetype($upload['name']);
}
if (!$this->check_img_type($upload['type']))
{
$this->error_msg = $GLOBALS['_LANG']['invalid_upload_image_type'];
$this->error_no = ERR_INVALID_IMAGE_TYPE;
return false;
}
/* 允许上传的文件类型 */
$allow_file_types = '|GIF|JPG|JEPG|PNG|BMP|SWF|';
if (!check_file_type($upload['tmp_name'], $img_name, $allow_file_types))
{
$this->error_msg = $GLOBALS['_LANG']['invalid_upload_image_type'];
$this->error_no = ERR_INVALID_IMAGE_TYPE;
return false;
}
if ($this->move_file($upload, $img_name))
{
return str_replace(ROOT_PATH, '', $img_name);
}
else
{
$this->error_msg = sprintf($GLOBALS['_LANG']['upload_failure'], $upload['name']);
$this->error_no = ERR_UPLOAD_FAILURE;
return false;
}
}
上面这个函数里面有return false 我调试的时候,它只执行了一半,但是又不知道它执行到哪里。。。。该怎么测试呢?
{
/* 没有指定目录默认为根目录images */
if (empty($dir))
{
/* 创建当月目录 */
$dir = date('Ym');
$dir = ROOT_PATH . $this->images_dir . '/' . $dir . '/';
}
else
{
/* 创建目录 */
$dir = ROOT_PATH . $this->data_dir . '/' . $dir . '/';
if ($img_name)
{
$img_name = $dir . $img_name; // 将图片定位到正确地址
}
}
/* 如果目标目录不存在,则创建它 */
if (!file_exists($dir))
{
include("lib_base.php");
if (!make_dir($dir))
{
/* 创建目录失败 */
$this->error_msg = sprintf($GLOBALS['_LANG']['directory_readonly'], $dir);
$this->error_no = ERR_DIRECTORY_READONLY;
return false;
}
}
if (empty($img_name))
{
$img_name = $this->unique_name($dir);
$img_name = $dir . $img_name . $this->get_filetype($upload['name']);
}
if (!$this->check_img_type($upload['type']))
{
$this->error_msg = $GLOBALS['_LANG']['invalid_upload_image_type'];
$this->error_no = ERR_INVALID_IMAGE_TYPE;
return false;
}
/* 允许上传的文件类型 */
$allow_file_types = '|GIF|JPG|JEPG|PNG|BMP|SWF|';
if (!check_file_type($upload['tmp_name'], $img_name, $allow_file_types))
{
$this->error_msg = $GLOBALS['_LANG']['invalid_upload_image_type'];
$this->error_no = ERR_INVALID_IMAGE_TYPE;
return false;
}
if ($this->move_file($upload, $img_name))
{
return str_replace(ROOT_PATH, '', $img_name);
}
else
{
$this->error_msg = sprintf($GLOBALS['_LANG']['upload_failure'], $upload['name']);
$this->error_no = ERR_UPLOAD_FAILURE;
return false;
}
}
上面这个函数里面有return false 我调试的时候,它只执行了一半,但是又不知道它执行到哪里。。。。该怎么测试呢?
作者: hxdyh 发布时间: 2010-01-26
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28