Ubuntu next File_get_contents returns an empty string

Source: Internet
Author: User
Tags fpm soap mcrypt wsdl

Ubuntu next File_get_contents returns an empty string

    • |
    • Browse:302
    • |
    • Updated: 2014-03-30 10:11

The problem at the beginning of this article is that PHP does not work soapclient, and finally file_get_contents returns an empty string, solving the problem by solving the soapclient problem.

Tools/Materials
    • PHP Installation Extension Soap
Method/Step
    1. 1

      In the recent PHP code, the execution of the

      $soapclient = new SoapClient (' Http://sdk.entinfo.cn:8060/webservice.asmx?WSDL ');

      This statement throws an exception:

      Fatal error:uncaught SoapFault exception: [WSDL] soap-error:parsing wsdl:couldn ' t load from ' http://sdk.entinfo.cn:806 0/webservice.asmx? WSDL ': Start tag expected, ' < ' not found In/root/www/test.php:2stack trace

    2. 2

      First check to see if PHP has a SOAP extension installed. See phpinfo for a SOAP extension installed

    3. 3

      Judging by the abnormal situation, the meaning is probably even the start tag of the document is not read,

      1) direct access in the browser, found to be possible,

      2) Curl is also possible.

    4. 4

      1) then use file_get_contents (), get the content, found that the return is an empty string.

      2) then check the php.ini in the Allow_url_open, found also open this

      3) The following tests are carried out:

      $file = fopen (' http://www.example.com/', ' RB '); Var_dump (Stream_get_meta_data ($file));

    5. 5

      /* Output: Array (Ten) { 

       ["Wrapper_data"]=>   Array (2) { 

            ["Headers"]=>    array (0) {   }  

            ["Readbuf"]=>    resource ($) of type (stream)  

      ["Wrapper_type"]= >  string (4) "Curl"

       ["Stream_type"]=>  string (4) "Curl"

       ["mode"]=>  string (2) "RB"

       ["Unread_bytes"]=>  int (0)

       ["seekable"]=>  bool ( False)  

      ["uri"]=>  string "http://www.example.com/"

       ["Timed_out"]=>   BOOL (false)

       ["blocked"]=>  bool (True)

       ["EOF"]=>  bool (False)}

      */

    6. 6

      The result of the output,

      Wrapper_type is curl, and wrapper_data is empty, which is not normal,

      Normally wrapper_type should contain the response header information in the Http,wrapper_data array.

      The discovery of this phenomenon is related to the--with-curlwrappers compiler option, so look at the PHP compilation parameters:

      $ php-i | grep Configure

    7. 7

      Configure Command = './configure '--prefix=/usr/local/php '--with-config-file-path=/usr/local/php/etc '-- With-mysql=/usr/local/mysql '--with-mysqli=/usr/local/mysql/bin/mysql_config '--with-iconv-dir=/usr/local '-- With-zlib '--with-libxml-dir=/usr '--enable-xml '--enable-bcmath '--enable-shmop '--enable-sysvsem '-- Enable-inline-optimization '--with-curl '--with-curlwrappers '--enable-mbregex '--enable-fpm '-- Enable-mbstring '--with-mcrypt '--with-openssl '--with-mhash '--enable-pcntl '--enable-sockets '--with-xmlrpc ' '--enable-zip '--enable-soap '--enable-bcmath '

    8. 8

      --with-curlwrappers is enabled, the problem should be here, check the usefulness of this compilation option:

      $./ Configure--help | grep curlwrappers

       --with-curlwrappers     experimental:use cURL for URL streams

      It seems--with-curlwrappers This compile option is used to handle the URL stream, but there is a huge experimental in front of the word, still in the experiment. The existing workaround is to recompile PHP and remove "--with-curlwrappers":

    9. 9

      1) $ cd/path/to/php-5.3.6 (Switch to PHP installation directory)

      2) $ make clean (be sure to do clean)

      3) $./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql-- With-mysqli=/usr/local/mysql/bin/mysql_config--with-iconv-dir=/usr/local--with-zlib--WITH-LIBXML-DIR=/USR-- Enable-xml--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--with-curl--enable-mbregex --ENABLE-FPM--enable-mbstring--with-mcrypt--with-openssl--with-mhash--enable-pcntl--enable-sockets-- With-xmlrpc--enable-zip--enable-soap--enable-bcmath-with-gd--with-jpeg-dir=/usr--with-png-dir=/usr-- Enable-gd-native-ttf

      4) $ make && make install

      5) $ cd/usr/local/php/bin# Delete the old php binary file and replace it with the new, the Mac will generate the Php.dsym file after recompiling, other Linux system please handle the RM PHP && MV Yourself Php.dsym PHP

      6) Restart PHP
    10. 10

      When you are done, do another test:

      $file = fopen (' http://www.example.com/', ' RB '); Var_dump (Stream_get_meta_data ($file));

      /* results are as follows:

      Array (10) {

      ["Wrapper_data"]=> Array (12) {

      [0]=> string ("http/1.0 302 Found")

      [1]=> string ("location:http://www.iana.org/domains/example/")

      [2]=> string ("Server:bigip")

      [3]=> string ("Connection:close")

      [4]=> string ("content-length:0")

      [5]=> string (http/1.1) "OK"

      [6]=> string ("Date:sun, Mar 06:12:27 GMT")

      [7]=> string "server:apache/2.2.3 (CentOS)"

      [8]=> string ("last-modified:wed, 17:13:15 GMT")

      [9]=> string (+) "vary:accept-encoding"

      [10]=> string ("Connection:close")

      [11]=> string (content-type:text/html) "; Charset=utf-8 "

      }

      ["Wrapper_type"]=> string (4) "http"

      ["Stream_type"]=> string "Tcp_socket/ssl"

      ["Mode"]=> string (2) "RB"

      ["Unread_bytes"]=> Int (1225)

      ["Seekable"]=> bool (FALSE)

      ["uri"]=> string ("http://www.example.com/")

      ["Timed_out"]=> bool (FALSE)

      ["Blocked"]=> bool (TRUE)

      ["EOF"]=> bool (false)}*/

    11. 11

      Wrapper_type became a http,wrapper_data and was filled, and everything returned to normal.

      So one conclusion: careful use of--with-curlwrappers

Ubuntu next File_get_contents returns an empty string

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.