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 513027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:22:49+00:00 2026-05-13T07:22:49+00:00

I am in a predicament here. My PHP code used to work but since

  • 0

I am in a predicament here. My PHP code used to work but since I upgraded to PHP 5.2.6 I now get:

Warning: domdocument::domdocument() expects parameter 2 to be long, string given in C:\xamps older\xampp167\htdocs\test\myphp\CSR Demo pack\csr\output.php on line 46

Fatal error: Call to undefined method domdocument::loadHTML() in C:\xamps older\xampp167\htdocs\test\myphp\CSR Demo pack\csr\output.php on line 50

Here is the source:

<html>
    <head>
    </head>

    <body>

        <?php

        //error_reporting(0);

        /********** outputer **********/

        $bool=file_exists("data/tcmpsr.txt");
        if ($bool == 1)
        {
            $numstr=file_get_contents("data/tcmpsr.txt");
            if ($numstr <> "")
            {
                $NumOfTitleChars= $numstr;
            }
        }
        Else
        {

        }

        $bool=file_exists("data/dcmpsr.txt");
        if ($bool == 1)
        {
            $numstr=file_get_contents("data/dcmpsr.txt");
            if ($numstr <> "")
            {
             $NumOfDtlChars = $numstr;
            }
        }
        Else
        {

        }

        /*** A new DOM object ***/
            $dom = new DOMDocument('1.0','utf-8');

            /*** load the html into the object ***/
            $html = file_get_contents("data/csr.html");
            $dom->loadHTML($html);

            /*** discard white space ***/
            $dom->preserveWhiteSpace = false;

            /*** get the tags by its tag name ***/
            $artclArray = $dom->getElementsByTagName('div');
            $hdArray = $dom->getElementsByTagName('h2');
            $spanArray = $dom->getElementsByTagName('span');

            $i=0;
            $x=0;
            $y=0;
            $z=0;

        foreach ($artclArray as $memberid)
        {
            $divArray[$x]=$memberid->nodeValue;
            $x++;
        }

        foreach ($hdArray as $memberid)
        {
            $hdlsArray[$y]=$memberid->nodeValue;
            $y++;
        }

        foreach ($spanArray as $memberid)
        {
            $dtlsArray[$z]=$memberid->nodeValue;
            $z++;
        }

        $hdsele=0;
        foreach($hdlsArray as $elemid)
        {
            $AmountOfHdlChars=$NumOfTitleChars;
            $eachTitle=$elemid;

            for ($count=0; $count<$AmountOfHdlChars; $count++)
            {
                $chara[$count]=$eachTitle[$count];
            }
            $smallTitle=implode($chara);
            $shortTitleArray[$hdsele]=$smallTitle;
            $hdsele++;
        }

        $dtlele=0;
        foreach($dtlsArray as $elemid)
        {
            $AmountOfDtlChars=$NumOfDtlChars;
            $eachDetail=$elemid;

            for ($count=0; $count<$AmountOfDtlChars; $count++)
            {
                $chara[$count]=$eachDetail[$count];
            }
            $smallDtl=implode($chara);
            $shortDtlArray[$dtlele]=$smallDtl;
            $dtlele++;
        }
        //echo "".$shortTitleArray[0]."<br />";
        //echo "".$shortDtlArray[0]."<br />";
        //echo "".$divArray[0]."<br />";

        //The Result is three arrays "shortTitleArray", "divArray" and //"shortDtlArray".
        //hdlsArray and dtlsArray contain full actual headlines and details.


        /******************************/

        ?>

        </body>
</html>

After doing some research online I found that Zend extensions could be the cause. Here is what my Zend setup looks like.

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with the ionCube PHP Loader v3.1.34, Copyright (c) 2002-2009, by ionCube Ltd., and
with Zend Extension Manager v1.2.0, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies

I have tested this code on several new Windows systems and it has failed on all. This leads me to believe that most, if not many, webhosts might be using a similar setup to the one I have. The common solution, based on what I have read, is to disable Zend or comment out specific areas of the php.ini file. Because this is part of a script meant for distribution, most of my customers will not have direct access to the php.ini nor have access rights to modify webserver settings such as Zend extensions.

How do I solve this in code? Is there a workaround? Or is there an alternative to using DOMDocument?

  • 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-13T07:22:49+00:00Added an answer on May 13, 2026 at 7:22 am

    You could try SimpleXML, as an alternative to DOMDocument. It should work out-of-the-box on all PHP5 installations.

    For example, this should be pretty close to what your DOMDocument code was meant to do:

    <?php
    // Load the string and create a SimpleXMLElement
    $html_string = file_get_contents("data/csr.html");
    $root = new SimpleXMLElement($html_string);
    
    // Fetch all div, h2 and span values
    $divs = $h2s = $spans = array();
    foreach ($xml->div as $div) {
        $divs[] = $div;
    }
    foreach ($xml->h2 as $h2) {
        $h2s[] = $h2;
    }
    foreach ($xml->span as $span) {
        $spans[] = $span;
    }
    
    // etc...
    ?>
    

    Haven’t tested it tho, so you may have to adapt it a bit.

    There are also a number of other alternatives to parse XML documents (and most valid HTML documents, by extension). See PHP: XML Manipulation.

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

Sidebar

Ask A Question

Stats

  • Questions 245k
  • Answers 245k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You might want to try using the 'domready' event. Once… May 13, 2026 at 8:12 am
  • Editorial Team
    Editorial Team added an answer The shape file defines some vectorized two dimensional area(s). Once… May 13, 2026 at 8:12 am
  • Editorial Team
    Editorial Team added an answer I find this form to be ever-so-slightly more readable: bool… May 13, 2026 at 8:12 am

Related Questions

I am in the following predicament, i currently use Subversion for my source control
I used to think I was a reasonably intelligent person. apple's threading programming guide,
Walter Rumsby provided a great answer to Where to place JavaScript in an HTML
My question is more of a best practices question on how to implement unowned
I am in a position where I can choose the client browser for my

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.