Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过php请求返回html中的http内容?_Php_Jquery - Fatal编程技术网

如何通过php请求返回html中的http内容?

如何通过php请求返回html中的http内容?,php,jquery,Php,Jquery,我有一些内容(一些广告)的http地址。比方说 我想在html页面上返回此内容。比如说 <div></div> 首先我必须连接到这个http://a,然后我必须在div中显示内容(通过jquery?)。我能做些什么呢?您可以通过jQuery使用: 或者通过PHP使用: 您可以通过jQuery使用: 或者通过PHP使用: 通过多种方式,您可以使用PHP获取网站内容,如: <?php function curl_post($url){ $

我有一些内容(一些广告)的http地址。比方说

我想在html页面上返回此内容。比如说

<div></div>


首先我必须连接到这个
http://
a,然后我必须在div中显示内容(通过jquery?)。我能做些什么呢?

您可以通过
jQuery
使用:

或者通过
PHP
使用:


您可以通过
jQuery
使用:

或者通过
PHP
使用:


通过多种方式,您可以使用PHP获取网站内容,如:

<?php
    function curl_post($url){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $curl_response = curl_exec($ch);
        curl_close($ch);
        return $curl_response;
    }

    $content = curl_post('http://servername/submit/rest/getHtmlAdvertisements/');
?>

现在,您可以将
代码编辑为以下内容以显示内容:

<div><?php echo $content; ?></div>


或者像这样使用:


通过多种方式,您可以使用PHP获取网站内容,如:

<?php
    function curl_post($url){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $curl_response = curl_exec($ch);
        curl_close($ch);
        return $curl_response;
    }

    $content = curl_post('http://servername/submit/rest/getHtmlAdvertisements/');
?>

现在,您可以将
代码编辑为以下内容以显示内容:

<div><?php echo $content; ?></div>


或者像这样使用:


<?php
    $content = file_get_contents('http://servername/submit/rest/getHtmlAdvertisements/');
    echo $content;
?>