Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7496847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:49:04+00:00 2026-05-29T18:49:04+00:00

I see lots of php libraries that can parse html. A nice example is

  • 0

I see lots of php libraries that can parse html. A nice example is QueryPath which mimics the Jquery Api.

However, I am looking to analyse phtml. So, not only would the library be good at analysing the DOM, but also be good at analysing the php processing instructions. e.g The Php Document Object Model or PDOM.

A document like this:

<?php
require 'NameFinder.php';
$title = 'Wave Hello';
$name = getName();
?><html>
<head>
<title><?php echo $title ?></title>
</head>
<body>
<h1>Hello <?php echo $name ?></h1>
<p>Blah Blah Blah</p>
</body>

I’d like to be able to use this kind of php library to read things like:

  • the inner html of a DOM node, found by xpath or css selector.

as well possibly offering things like:

  • a list of php functions/method invoked in the script
  • values of php variables
  • pages required by that page
  • a list of php variables used before line 5
  • a list of php variables used before the 1st para of the body element

I could spend some time peicing something together, borrowing code from things like phpdocumentor and Zend Framework Reflection, using the in-built DOM Api, introspection and string manipulation, etc.

But, if there is some kind of *phtmlQuery” library out there that can do these kinds of things then it will handy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T18:49:06+00:00Added an answer on May 29, 2026 at 6:49 pm

    To get the processing instructions (and other nodes) from your files, you can use DOM and XPath:

    $dom = new DOMDocument;
    $dom->loadHTMLFile('/path/to/your/file/or/url');
    $xpath = new DOMXPath($dom);
    foreach ($xpath->query('//processing-instruction()') as $pi) {
        echo $dom->saveHTML($pi), PHP_EOL;
    }
    

    This will output:

    <?php require 'NameFinder.php';
    $title = 'Wave Hello';
    $name = getName();
    ?>
    <?php echo $title ?>
    <?php echo $name ?>
    

    This will work with broken HTML. You can find additional libraries at

    • How do you parse and process HTML/XML in PHP?

    Once you got the processing instructions, you can either run them through the native Tokenizer or try some of these:

    • https://github.com/Andrewsville/PHP-Token-Reflection
    • https://github.com/manuelpichler/staticReflection
    • https://github.com/nikic/PHP-Parser

    Those won’t magically give you the information you seek out of the box, so you will likely need to write a few additional lines on your own.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have lots of experience of writing php scripts that are run in the
Thanks for the contributions so far - I can see now that $rowq is
What is BOF ? I can see lots of mentions of it but can
Can I access a cookie written with jQuery's cookie plug-in with PHP? I know
I see lots of jquery tutorials from building the submit form from scratch, and
Despite trying lots of things (see below), I can't get rid of the Bytes
I see lots of TDD practitioners following this cycle: 1) Write your test as
I see lots of articles saying how great IoC and DI are and none
I have lots of home directories under /ifshome on Linux. I want to see
I'm trying to learn PHP programming through trial, error and lots and lots of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.