php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33983 bugy result from get_all_tokens()
Submitted: 2005-08-03 18:14 UTC Modified: 2005-08-04 12:39 UTC
From: smart at open-publisher dot net Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.0.4 OS: XP
Private report: No CVE-ID: None
 [2005-08-03 18:14 UTC] smart at open-publisher dot net
Description:
------------
When parsing files that contains mixed html + php code with the function get_all_tokens() the returned array contains a lot of html fragments. Also when parsing some files the  returned array cause heavy problems. The Server return "document contains no data". But the same file is correctly parsed by the php interpreter. So i think the problem is the function get_all_tokens().


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-03 19:30 UTC] smart at open-publisher dot net
You can see that the array $tokens contains html fragments


<?php
    $tokens = token_get_all(file_get_contents("test.php"));
    echo "<pre>";var_dump($tokens);echo "</pre>";
?>

---- snip - test.php file to parse ----------
<html>
<head>
<meta name="keywords" content="">
<title>SMART3 - <?php echo "Hello World"; ?></title>
<script language="JavaScript" type="text/JavaScript">
</script>
</head>
<body>
</body>
</html>
---- end snip - test.php file to parse ----------
 [2005-08-03 22:20 UTC] sniper@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

It's inline HTML..RTFM..

 [2005-08-04 12:39 UTC] smart at open-publisher dot net
Thanks for the lovely tip ... RTFM. 

The problem is that the content of this array that the function get_all_tokens() return throw php in nirvana. Server message: "Document contains no data". It toke hours to find out that this bug is undebugable just by analyzing code line by line. A simple class methode which is correctly executed until the last bracked hangs. 

class test
{

}

It's definetely a php internal error.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 15:01:29 2024 UTC