问题描述
我在 PHP 4 上有一个旧站点。我想将它移到 PHP 8,因此我已经开始工作。 我用 DBF-CLASS 读取 dbf 文件。但是我无法让它在 PHP 8 上工作。我已经检查了代码并确保我没有错误,但我仍然无法读取 dbf 文件。或者说我可以阅读它们但不能打印信息。
有没有人让 DBF 类在 PHP 8 上工作,或者有任何其他想法如何读取我曾经读过的 dbf 文件,这些文件可以使用 PHP 8 添加到 MysqL 数据库中。我在此处找到的示例非常古老。我猜是因为 dbf 文件不再那么常见了。
感谢任何提示。
“更新” 我让它工作。创建新的 dbf_class 时,我收到错误消息“与它们的类同名的方法在未来版本的 PHP 中将不再是构造函数”
因此,我将函数 dbf_class() 改为函数 __construct(),因为该类名为 dbf_class。
旧代码: 类 dbf_class {
var $dbf_num_rec; //Number of records in the file
var $dbf_num_field; //Number of columns in each row
var $dbf_names = array(); //information on each column ['name'],['len'],['type']
//These are private....
var $_raw; //The raw input file
var $_rowsize; //Length of each row
var $_hdrsize; //Length of the header information (offset to 1st record)
var $_memos; //The raw memo file (if there is one).
function **dbf_class($filename) {**
if ( !file_exists($filename)) {
echo 'Not a valid DBF file !!!'; exit;
}
$tail=substr($filename,-4);
if (strcasecmp($tail,'.dbf')!=0) {
echo 'Not a valid DBF file !!!'; exit;
}
…………
新代码: 类 dbf_class {
var $dbf_num_rec; //Number of records in the file
var $dbf_num_field; //Number of columns in each row
var $dbf_names = array(); //information on each column ['name'],['type']
//These are private....
var $_raw; //The raw input file
var $_rowsize; //Length of each row
var $_hdrsize; //Length of the header information (offset to 1st record)
var $_memos; //The raw memo file (if there is one).
function **__construct($filename)** {
if ( !file_exists($filename)) {
echo 'Not a valid DBF file !!!'; exit;
}
$tail=substr($filename,'.dbf')!=0) {
echo 'Not a valid DBF file !!!'; exit;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)