Call to undefined function xml_parser_create()

21,927

Solution 1

Under ubuntu you can do the same as @Tarun pointed

apt-get install php-xml
apt-get search php |grep xml

Solution 2

You need to remove php-xml and use php70u-xml

yum purge php-xml; yum install -y php70u-xml

Many people install php using some tutorial which will enable an external repo. Php gets installed using packages from this external repo. While installing extensions they try and use package names from default repo. So that is what your problem was.

Always first see where your packages are installed from

yum list installed | grep php

Then always make sure you that you choose the package which belongs to the same repo

yum search php | grep xml
Share:
21,927
Dibya Sahoo
Author by

Dibya Sahoo

An experienced professional with a successful track record in handling a profitable business unit with specialization in Product Management and Development, currently doing everything in this domain knowledge for Pepipost to establish itself as the industry leader.

Updated on July 24, 2022

Comments

  • Dibya Sahoo
    Dibya Sahoo almost 2 years

    Could you please help me in resolving this conflict. I am tryin to run a xml_parse_create.
    My server configurations:
    [root@server ~]# php -v
    PHP 7.0.22 (cli) (built: Aug 7 2017 16:18:27) ( NTS )

    [root@server ~]# nginx -v
    nginx version: nginx/1.10.2

    OS: CentOS 7.3.1611 (Core)

    Details of my YUM installation:

    [root@server ~]# yum list installed | grep php
    php70u-cli.x86_64                       7.0.22-2.ius.centos7           @ius     
    php70u-common.x86_64                    7.0.22-2.ius.centos7           @ius     
    php70u-fpm.x86_64                       7.0.22-2.ius.centos7           @ius     
    php70u-fpm-nginx.noarch                 7.0.22-2.ius.centos7           @ius     
    php70u-mysqlnd.x86_64                   7.0.22-2.ius.centos7           @ius     
    php70u-pdo.x86_64                       7.0.22-2.ius.centos7           @ius  
    

    Here is the details of the investigation:

    I tried executing following code in test.php:

    <?php
    $xml_parser = xml_parser_create("");
    print $xml_parser;<br>
    ?>
    

    [root@server ~]# php /tmp/test.php
    PHP Fatal error: Uncaught Error: Call to undefined function

    [root@server ~]# sudo yum install php-xml
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * base: repo1.ash.innoscale.net
    * epel: fedora-epel.mirrors.tds.net
    * extras: mirror.es.its.nyu.edu
    * ius: ius.mirror.constant.com
    * remi-safe: repo1.ash.innoscale.net
    * updates: mirrors.advancedhosters.com
    * webtatic: us-east.repo.webtatic.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package php-xml.x86_64 0:5.4.16-42.el7 will be installed
    --> Processing Dependency: php-common(x86-64) = 5.4.16-42.el7 for package: php-xml-5.4.16-42.el7.x86_64
    --> Running transaction check
    ---> Package php-common.x86_64 0:5.4.16-42.el7 will be installed
    --> Processing Conflict: php70u-common-7.0.22-2.ius.centos7.x86_64 conflicts php-common < 7.0.22
    --> Finished Dependency Resolution
    Error: php70u-common conflicts with php-common-5.4.16-42.el7.x86_64
    You could try using --skip-broken to work around the problem
    You could try running: rpm -Va --nofiles --nodigest