Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php中安装二维码库_Php - Fatal编程技术网

如何在php中安装二维码库

如何在php中安装二维码库,php,Php,我是PHP新手&我想使用我下载的zip文件中的PHP QR代码库,但不知道在Linux中把这些内容放在哪里让我的PHP识别 我可以把它们放在任何地方吗?或者在哪里放置和安装它们的良好做法是什么 感谢安装文件提供的帮助,它看起来非常简单: 解压lib文件夹中的文件(例如/var/www/lib/qrlib) 在PHP页面中,包括qrlib文件 你就完了 下面是一个代码示例,如果您的PHP页面位于/var/www文件夹中,该代码应该可以工作。在/var/www/qrtest.php文件中编写此代

我是PHP新手&我想使用我下载的zip文件中的PHP QR代码库,但不知道在Linux中把这些内容放在哪里让我的PHP识别

我可以把它们放在任何地方吗?或者在哪里放置和安装它们的良好做法是什么


感谢安装文件提供的帮助,它看起来非常简单:

  • 解压lib文件夹中的文件(例如/var/www/lib/qrlib)

  • 在PHP页面中,包括qrlib文件

  • 你就完了

下面是一个代码示例,如果您的PHP页面位于/var/www文件夹中,该代码应该可以工作。在/var/www/qrtest.php文件中编写此代码,并尝试从浏览器访问它

<?php

//include only that one, rest required files will be included from it
include "./lib/qrlib/qrlib.php"

//write code into file, Error corection lecer is lowest, L (one form: L,M,Q,H)
//each code square will be 4x4 pixels (4x zoom)
//code will have 2 code squares white boundary around 

QRcode::png('PHP QR Code :)', 'test.png', 'L', 4, 2);

//same as above but outputs file directly into browser (with appr. header etc.)
//all other settings are default
//WARNING! it should be FIRST and ONLY output generated by script, otherwise
//rest of output will land inside PNG binary, breaking it for sure
QRcode::png('PHP QR Code :)');

//show benchmark
QRtools::timeBenchmark();

//rebuild cache
QRtools::buildCache();

//code generated in text mode - as a binary table
//then displayed out as HTML using Unicode block building chars :)
$tab = $qr->encode('PHP QR Code :)');
QRspec::debug($tab, true);

?>

您的PHP应用程序结构是什么?您可以创建一个名为“lib”左右的嵌套文件夹。从一个页面中,你可以通过包含它来包含它。我只在/var/www/html中部署了一个简单的PHP页面&没有其他内容。我发布了一个答案,如果你的apache服务器配置良好,应该可以使用。我遵循了上面的步骤,但是当我在浏览器中点击PHP时,没有显示任何内容。你的默认PHP文件在哪里?你能访问它吗?我按照上面的步骤操作,但当我在浏览器中点击php时,什么也没有显示。我检查了日志,可以看到以下错误:PHP解析错误:语法错误,意外的“QRcode”(T_字符串)。它根本没有重新认识QRCode功能,这可能是因为包含路径不好。你能告诉我你拥有的“qrtest.php”文件的完整路径和“qrlibrary.php”文件的完整路径吗?OK..我更正了路径&现在我在浏览器中看到错误“图像无法显示,因为它包含错误”。注意,我需要在浏览器中直接显示二维码&因此我只保留include line&QRcode::png('PHP二维码:);行但没有运气,日志现在没有错误