如何通过php请求返回html中的http内容?
我有一些内容(一些广告)的http地址。比方说 我想在html页面上返回此内容。比如说如何通过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){ $
<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;
?>