PHP Parse error: syntax error, unexpected '['
Hi, I have problem when implement your library. it return an error when i try to run file escpos-php-development/example/interface/windows-usb.php on browser.
PHP Parse error: syntax error, unexpected '[' in /var/www/escpos-php-development/src/Mike42/Escpos/PrintConnectors/WindowsPrintConnector.php on line 158
any idea how to solve this?
here is the content of windows-usb.php
try {
// Enter the share name for your USB printer here
// $connector = "Receipt Printer";
$connector = new WindowsPrintConnector("\\%DESKTOP-688H036%\Receipt Printer");
/* Print a "Hello world" receipt" */
$printer = new Printer($connector);
$printer -> text("Hello World!\n");
$printer -> cut();
/* Close printer */
$printer -> close();
} catch (Exception $e) {
echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
}
I already install the printer driver on a DESKTOP-688H036 and also share it as "Receipt Printer".
Thank you.
I try to do the echo "hello word" command and it printed. but when i want to do from browser it say error.
Have you verified that your PHP version meets the 5.4 minimum listed in the README?
These days, the unexpected [ array bracket is commonly seen on outdated PHP versions. The short array syntax is available since PHP >= 5.4.
From StackOverflow, PHP parse/syntax errors; and how to solve them?