작은 프로젝트의 바코드 생성을 위해 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)를 사용해보십시오. 어딘가에 오타가 있다고 생각합니다. 또한 GET 변수는 URL을 보면 쉽게 확인할 수 있어야합니다. –
변수 $ _GET이 (가) URL에 있습니까 ?? 'test.php? invoice = 45' – tttony
Site.com/tmp/barcodegen.1d-php5.v4.1.0/test.html?invoice=33로 이동하면 URL을 정확하게 확인할 수 있습니다. – NRGdallas