我正在使用PHP爲小型項目生成條形碼,但似乎無法使其工作。我是PHP的初學者,似乎無法找到我做錯了什麼。PhP獲取數據未分配給變量
這裏是我的代碼:
<?php
// Including all required classes
require_once('class/BCGFontFile.php');
require_once('class/BCGColor.php');
require_once('class/BCGDrawing.php');
// Including the barcode technology
require_once('class/BCGcode39.barcode.php');
// Loading Font
$font = new BCGFontFile('./class/font/Arial.ttf', 18);
// The arguments are R, G, B for color.
$color_black = new BCGColor(0, 0, 0);
$color_white = new BCGColor(255, 255, 255);
//$invoice="36";
$drawException = null;
$invoice = $_GET['invoice'];
try {
$code = new BCGcode39();
$code->setScale(2); // Resolution
$code->setThickness(30); // Thickness
$code->setForegroundColor($color_black); // Color of bars
$code->setBackgroundColor($color_white); // Color of spaces
$code->setFont($font); // Font (or 0)
$code->parse($invoice); // Text
} catch(Exception $exception) {
$drawException = $exception;
}
的問題是該行22 "$invoice = $_GET['invoice'];"
實際上不拉得的數據!如果我取消註釋"//$invoice="36";
並註釋掉get部分,代碼將正常工作。
任何想法?
嘗試使用print_r($ _GET)或print_r($ _REQUEST)來查看實際獲得的值。我猜猜這裏有一個錯字。另外,只需查看URL即可輕鬆檢查GET變量。 – 2012-03-28 21:46:23
變量$ _GET在url中? 'test.php的?發票= 45' – tttony 2012-03-28 21:47:24
我可以去Site.com/tmp/barcodegen.1d-php5.v4.1.0/test.html?invoice=33 – NRGdallas 2012-03-28 21:53:15