我使用phplint检查我的PHP代码。我是om Windows 8.1,我的编辑器是崇高文本3。下面是我的一个代码片段:
<?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()‘(仍然)未声明。从它的用法中猜测签名。提示:最好在函数使用之前声明它们
1: undeclared function 'header()' used only once: misspelled? 3: variable '$singleHeight' assigned but never used 4: variable '$singleWidth' assigned but never used 5: function 'imagecreatetruecolor()' (still) not declared. Guessing signature from its usage. Hint: it's better to declare the functions before their usage 5: undeclared function 'imagecreatetruecolor()' used only once: misspelled? 6: function 'imagecolorallocate()' (still) not declared. Guessing signature from its usage. Hint: it's better to declare the functions before their usage 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 7: undeclared function 'imagefill()' used only once: misspelled?那些未声明的函数是什么?代码本身运行良好。
发布于 2014-04-22 03:13:23
我假设你在使用这个PHPLint http://www.icosaedro.it/phplint/phplint-on-line.html?
默认情况下,它似乎没有加载任何标准库,所以当您检查linter从零开始的代码时,没有任何声明。
当您在服务器上运行代码时,启用了GD和标准PHP函数(如header ),这样就可以正常工作了。
您可以将这些库添加到代码的顶部,如下所示
<?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);这将像这样输出
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.https://stackoverflow.com/questions/22067997
复制相似问题