首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >phplint未声明函数

phplint未声明函数
EN

Stack Overflow用户
提问于 2014-02-27 12:04:48
回答 1查看 864关注 0票数 3

我使用phplint检查我的PHP代码。我是om Windows 8.1,我的编辑器是崇高文本3。下面是我的一个代码片段:

代码语言:javascript
复制
<?php
header("Content-type: image/png");

$singleHeight = 129;
$singleWidth = 97;
$bild = imagecreatetruecolor(1170, 520);
$orange = imagecolorallocate($bild, 248, 154, 38);
imagefill($bild, 0, 0, $orange);

....

?>

这是phplint报告:

1:函数'header()‘(仍然)未声明。从它的用法中猜测签名。提示:最好在函数使用之前声明它们

代码语言:javascript
复制
 1: undeclared function 'header()' used only once: misspelled?
代码语言:javascript
复制
 3: variable '$singleHeight' assigned but never used
代码语言:javascript
复制
 4: variable '$singleWidth' assigned but never used
代码语言:javascript
复制
 5: function 'imagecreatetruecolor()' (still) not declared. Guessing signature from its usage. Hint: it's better to declare the functions before their usage
代码语言:javascript
复制
 5: undeclared function 'imagecreatetruecolor()' used only once: misspelled?
代码语言:javascript
复制
 6: function 'imagecolorallocate()' (still) not declared. Guessing signature from its usage. Hint: it's better to declare the functions before their usage
代码语言:javascript
复制
 6: undeclared function 'imagecolorallocate()' used only once: misspelled?     7: function 'imagefill()' (still) not declared. Guessing signature from its usage. Hint: it's better to declare the functions before their usage
代码语言:javascript
复制
 7: undeclared function 'imagefill()' used only once: misspelled?

那些未声明的函数是什么?代码本身运行良好。

EN

回答 1

Stack Overflow用户

发布于 2014-04-22 03:13:23

我假设你在使用这个PHPLint http://www.icosaedro.it/phplint/phplint-on-line.html

默认情况下,它似乎没有加载任何标准库,所以当您检查linter从零开始的代码时,没有任何声明。

当您在服务器上运行代码时,启用了GD和标准PHP函数(如header ),这样就可以正常工作了。

您可以将这些库添加到代码的顶部,如下所示

代码语言:javascript
复制
<?php /*. require_module 'gd'; .*/ ?>
<?php /*. require_module 'standard'; .*/ ?>
<?php
header("Content-type: image/png");

$singleHeight = 129;
$singleWidth = 97;
$bild = imagecreatetruecolor(1170, 520);
$orange = imagecolorallocate($bild, 248, 154, 38);
imagefill($bild, 0, 0, $orange);

这将像这样输出

代码语言:javascript
复制
BEGIN parsing of test-32AOqf
1:      <?php /*. require_module 'gd'; .*/ ?>
2:      <?php /*. require_module 'standard'; .*/ ?>
3:      <?php
4:      header("Content-type: image/png");
5:      
6:      $singleHeight = 129;
7:      $singleWidth = 97;
8:      $bild = imagecreatetruecolor(1170, 520);
9:      $orange = imagecolorallocate($bild, 248, 154, 38);
10:     imagefill($bild, 0, 0, $orange);
END parsing of test-32AOqf
==== test-32AOqf:7: notice: variable `$singleWidth' assigned but never used
==== test-32AOqf:6: notice: variable `$singleHeight' assigned but never used
==== ?: notice: unused package `stdlib/dummy.php'
==== ?: notice: unused module `mysql'
==== ?: notice: unused module `pcre'
==== ?: notice: required module `standard'
==== ?: notice: required module `gd'
Overall test results: 0 errors, 0 warnings.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22067997

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档