189 8069 5689

url访问php数据列表 php 获取url

PHP调用数据库中的URL地址进行跳转问题

在跳转的时候php一般默认你用的是相对地址所以会把域名自动加上,所以在存储地址的时候一般要把http://加上。

站在用户的角度思考问题,与客户深入沟通,找到昆玉网站设计与昆玉网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站设计、成都做网站、企业官网、英文网站、手机端网站、网站推广、域名与空间、网页空间、企业邮箱。业务覆盖昆玉地区。

如何能实现URL中修改参数访问具体PHP数据列表页

POST或者GET是网页提交数据的方式,get提交其参数会显示在URL上

数据提交方式和访问数据库数据基本没有关系,但是其提交的参数可以作为访问数据库的条件或者参数

举例:

list.php?name=a   这个是GET提交方式,其参数name的值是a,在list.php这个页面的程序中获取到值a,然后把a当做查询数据库的条件获取数据,比如说你查询表中name=a的数据,select * from 表名 where name=$_request["name"]。这个name=a也可以通过post提交,post提交就需要form表单。

希望对您有帮助。

url直接访问Php中方法

这是不可能的,你应该要把它实例化,

例如

myclass.php

?php

class test{

public function abc(){

echo "this is the function of abc";

}

}

//实例化

$mytest=new test();

//执行方法

$mytest-test();

当你浏览器输入这个网站的路径+myclass.php的时候,页面就会显示

this is the function of abc

php打开URL的几种方法

PHP中打开URL地址的几种方法总结,这里的函数主要用于小偷采集等函数。

1: 用file_get_contents 

以get方式获取内容 

复制代码 代码如下:

?php 

$url=''; 

$html = file_get_contents($url); 

//print_r($http_response_header); 

ec($html); 

printhr(); 

printarr($http_response_header); 

printhr(); 

示例代码2: 用fopen打开url, 

以get方式获取内容 

复制代码 代码如下:

$fp = fopen($url, 'r'); 

printarr(stream_get_meta_data($fp)); 

printhr(); 

while(!feof($fp)) { 

$result .= fgets($fp, 1024); 

echo "url body: $result"; 

printhr(); 

fclose($fp); 

示例代码3:用file_get_contents函数,以post方式获取url 

复制代码 代码如下:

?php 

$data = array ('foo' = 

'bar'); 

$data = http_build_query($data); 

$opts = array ( 

'http' 

= array ( 

'method' = 'POST', 

'header'= "Content-type: 

application/x-www-form-urlencoded" . 

"Content-Length: " . strlen($data) . 

"", 

'content' = $data 

), 

); 

$context = 

stream_context_create($opts); 

$html = 

file_get_contents('', false, $context); 

echo $html; 

示例代码4:用fsockopen函数打开url,以get方式获取完整的数据,包括header和body 

复制代码 代码如下:

function get_url 

($url,$cookie=false) { 

$url = parse_url($url); 

$query = 

$url[path]."?".$url[query]; 

ec("Query:".$query); 

$fp = fsockopen( 

$url[host], $url[port]?$url[port]:80 , $errno, $errstr, 30); 

if (!$fp) { 

return false; 

} else { 

$request = "GET $query HTTP/1.1"; 

$request .= "Host: $url[host]"; 

$request .= "Connection: Close"; 

if($cookie) $request.="Cookie: $cookie\n"; 

$request.=""; 

fwrite($fp,$request); 

while(!@feof($fp)) { 

$result .= @fgets($fp, 

1024); 

fclose($fp); 

return $result; 

//获取url的html部分,去掉header 

function GetUrlHTML($url,$cookie=false) { 

$rowdata = get_url($url,$cookie); 

if($rowdata) 

$body= 

stristr($rowdata,""); 

$body=substr($body,4,strlen($body)); 

return $body; 

return false; 

?

几种php访问url的方法

常用的就三种吧,

file_get_contents(), fopen, curl

一般用 curl 扩展的比较多,除此以外还有其他方法

fsockopen 啥的

php怎么访问url,如果访问如果返回true访问失败返回false,不要跳转, 就判断访问是否成

php访问url的四种方式

1.fopen方式

//访问指定URL函数

[php] view plain copy

print?

function access_url($url) {

if ($url=='') return false;

$fp = fopen($url, 'r') or exit('Open url faild!');

if($fp){

while(!feof($fp)) {

$file.=fgets($fp)."";

}

fclose($fp);

}

return $file;

}

2.file_get_contents方式(打开远程文件的时候会造成CPU飙升。file_get_contents其实也可以post)

[php] view plain copy

print?

$content = file_get_contents("httttp://w");

3.curl方式

[php] view plain copy

print?

function curl_file_get_contents($durl){

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $durl);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; // 获取数据返回

curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ; // 在启用 CURLOPT_RETURNTRANSFER 时候将获取数据返回

$r = curl_exec($ch);

curl_close($ch);

return $r;

}

4.fsockopen方式(只能获取网站主页信息,其他页面不可以)

[php] view plain copy

print?

$fp = fsockopen("", 80, $errno, $errstr, 30);

if (!$fp) {

echo "$errstr ($errno)br /\n";

} else {

$out="GET / HTTP/1.1\r\n";

$out.="Host: \r\n";

$out.="Connection: Close\r\n\r\n";

fwrite($fp, $out);

while (!feof($fp)) {

echo fgets($fp, 128);

}

fclose($fp);

}


网站栏目:url访问php数据列表 php 获取url
浏览地址:http://cdxtjz.cn/article/hphjes.html

其他资讯