相关疑难解决方法(0)

我如何使用PHP的Perl库?

我想从PHP应用程序中使用Perl库.我听说有可能.

我已经考虑过用PHP重写库的可能性,但我认为这不是一个好主意,因为它很难.

php embed perl

6
推荐指数
2
解决办法
4091
查看次数

如何在PHP中包含.pl(PERL)文件

我在php(index.php)中有两个页面,在Perl(dbcon.pl)中有另一个页面.

基本上我希望我的php文件只显示UI,所有数据操作都将在Perl文件中完成.

我试过index.pl

<?php include("dbcon.pl");?>
<html>
<br/>PHP</br>
</html>
Run Code Online (Sandbox Code Playgroud)

和dbcon.pl有

#!/usr/bin/perl
use strict;
use warnings;
use DBI;

use CGI::Simple;
my $cgi = CGI::Simple->new;
my $dsn = sprintf('DBI:mysql:database=%s;host=%s','dbname','localhost');

my $dbh = DBI->connect($dsn,root =>'',{AutoCommit => 0,RaisError=> 0});


my $sql= "SELECT * FROM products";
my $sth =$dbh->prepare($sql);
$sth->execute   or die "SQL Error: $DBI::errstr\n";
while (my @row = $sth->fetchrow_array){
print $cgi->header, <<html;
<div>&nbsp;@row[0]&nbsp;@row[1]&nbsp;@row[2]&nbsp;@row[3]&nbsp;@row[4]</div>
html
}
Run Code Online (Sandbox Code Playgroud)

但是当我在浏览器中运行index.php时,它会打印dbcon.pl文件中的所有代码而不是执行它

如何克服这个问题?

注意:我在Windows环境中运行它

还有其他办法吗?

php perl include

-5
推荐指数
1
解决办法
5467
查看次数

标签 统计

perl ×2

php ×2

embed ×1

include ×1