Note that there are some explanatory texts on larger screens.

plurals
  1. POphp, this array works in global but failed while putting inside class
    primarykey
    data
    text
    <p>I have following array, this works fine If i put in global and access the php with CLI but it gives following error while putting this same array in class.</p> <pre><code>'printer_1' =&gt; array( 't_char_set' =&gt; 'ch-latin-2', 'find' =&gt; array('Ä', 'Ö', 'Ü', 'ä', 'ö', 'ü' , 'à', 'â', 'ç', 'é', 'è', 'ê' , 'ë', 'ï', 'î', 'ì', 'ô', 'ò'), 'repl' =&gt; array(chr(142), chr(153), chr(154), chr(132), chr(148), chr(129), chr(133), chr(131), chr(135), chr(130), chr(138), chr(136), chr(137), chr(139), chr(140), chr(141), chr(147), chr(149)) ); </code></pre> <p>while putting this as a variable in class it's gives following error</p> <blockquote> <p>PHP Parse error: syntax error, unexpected '(', expecting ')' in xxx.php on line 6</p> </blockquote> <p>any clue ?</p> <p>edit: Here is the full class (I have removed the other functions to minimize the content.)</p> <pre><code>&lt;?php $K_printer = array( 'TM1' =&gt; array( /* Printer Setup */ 'width' =&gt; 40, 'translate' =&gt; true, 'p_char_set' =&gt; false, /* Printer Capabilities */ 'color' =&gt; false, 'barcode' =&gt; true, 'cut' =&gt; true, 'logo' =&gt; true, 'drawer' =&gt; true, 'fontselect' =&gt; true, 'reverse' =&gt; false, /* Character Translation Setup */ 't_char_set' =&gt; 'ch-latin-2', 'find' =&gt; array('Ä', 'Ö', 'Ü', 'ä', 'ö', 'ü' , 'à', 'â', 'ç', 'é', 'è', 'ê' , 'ë', 'ï', 'î', 'ì', 'ô', 'ò'), 'repl' =&gt; array(chr(142), chr(153), chr(154), chr(132), chr(148), chr(129), chr(133), chr(131), chr(135), chr(130), chr(138), chr(136), chr(137), chr(139), chr(140), chr(141), chr(147), chr(149)) ) ); // KByte // ===== if(!function_exists('kchr')){ function kbyte($val){ return pack('C', $val); } } class KP{ private $width; // output width (characters) private $translate; // use character translation private $printer_char_set; // printer character set // Constructor // =========== function __construct($printer_setup = false){ // Load Printer Setup // ================== $this -&gt; LoadSetup($printer_setup); } //removed other functions... // // Load Printer Setup // ================== function LoadSetup($printer = false){ global $K_printer; if(!isset($K_printer[$printer])){ $this -&gt; error('Unknown printer setup.'); return false; } $this -&gt; width = $K_printer[$printer]['width']; $this -&gt; translate = $K_printer[$printer]['translate']; $this -&gt; printer_char_set = $K_printer[$printer]['p_char_set']; return true; } } </code></pre> <p>?></p> <p>This works fine from PHP cli with following say t1.php file</p> <pre><code> $ep = new KP('TM1'); </code></pre> <p>but I i simply include this file in other class function "require('t1.php')", the $K_printer is passed as NULL in LoadSetup function so it's throwing error. (I did <code>error_log(print_r($K_printer, true));</code> to capture this in error.log file of apache2.</p> <pre><code>[Thu Dec 12 02:31:15 2013] [error] [client 10.0.2.2] NULL\n [Thu Dec 12 02:31:15 2013] [error] [client 10.0.2.2] Unknown printer setup. </code></pre> <p>really trying to find what is wrong since last night, finally wrote on stackoverflow to seek some expert advice.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload