#35286 [Fbk->Opn]: tokenizer ext drops final comment

From: Date: Sat, 19 Nov 2005 01:10:20 +0000
Subject: #35286 [Fbk->Opn]: tokenizer ext drops final comment
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-88518@lists.php.net to get a copy of this message
ID: 35286 Updated by: cellog@php.net Reported By: cellog@php.net -Status: Feedback +Status: Open Bug Type: Unknown/Other Function Operating System: n/a PHP Version: 5.0.5 New Comment: the original reproduce script has no closing newline - the newline does change the behavior Previous Comments: ------------------------------------------------------------------------ [2005-11-19 02:04:20] tony2001@php.net Doesn't drop anything here: The code: <?php $arr = token_get_all("<?php print 'foo'; # you'll see it print 'bar'; # but not this one "); foreach ($arr as $token) { if (is_array($token)) var_dump($token[1]); } ?> The output: string(6) "<?php " string(1) " " string(5) "print" string(1) " " string(5) "'foo'" string(2) " " string(16) "# you'll see it " string(5) "print" string(1) " " string(5) "'bar'" string(2) " " string(19) "# but not this one " ------------------------------------------------------------------------ [2005-11-19 01:53:39] cellog@php.net Description: ------------ The tokenizer extension is ignoring a final comment when tokenizing a script that does not contain a closing ?> Reproduce code: --------------- var_dump(token_get_all("<?php print 'foo'; # you'll see it print 'bar'; # but not this one")); Expected result: ---------------- array(13) { [0]=> array(2) { [0]=> int(366) [1]=> string(6) "<?php " } [1]=> array(2) { [0]=> int(266) [1]=> string(5) "print" } [2]=> array(2) { [0]=> int(369) [1]=> string(1) " " } [3]=> array(2) { [0]=> int(315) [1]=> string(5) "'foo'" } [4]=> string(1) ";" [5]=> array(2) { [0]=> int(369) [1]=> string(1) " " } [6]=> array(2) { [0]=> int(364) [1]=> string(16) "# you'll see it " } [7]=> array(2) { [0]=> int(369) [1]=> string(1) " " } [8]=> array(2) { [0]=> int(266) [1]=> string(5) "print" } [9]=> array(2) { [0]=> int(369) [1]=> string(1) " " } [10]=> array(2) { [0]=> int(315) [1]=> string(5) "'bar'" } [11]=> string(1) ";" [12]=> array(2) { [0]=> int(369) [1]=> string(1) " " } [13]=> array(2) { [0]=> int(364) [1]=> string(18) "# but not this one" } Actual result: -------------- array(13) { [0]=> array(2) { [0]=> int(366) [1]=> string(6) "<?php " } [1]=> array(2) { [0]=> int(266) [1]=> string(5) "print" } [2]=> array(2) { [0]=> int(369) [1]=> string(1) " " } [3]=> array(2) { [0]=> int(315) [1]=> string(5) "'foo'" } [4]=> string(1) ";" [5]=> array(2) { [0]=> int(369) [1]=> string(1) " " } [6]=> array(2) { [0]=> int(364) [1]=> string(16) "# you'll see it " } [7]=> array(2) { [0]=> int(369) [1]=> string(1) " " } [8]=> array(2) { [0]=> int(266) [1]=> string(5) "print" } [9]=> array(2) { [0]=> int(369) [1]=> string(1) " " } [10]=> array(2) { [0]=> int(315) [1]=> string(5) "'bar'" } [11]=> string(1) ";" [12]=> array(2) { [0]=> int(369) [1]=> string(1) " " } } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35286&edit=1

« previous php.bugs (#88518) next »