草庐IT

$http-get-post

全部标签

php - 如何有效地添加带有 a 的 GET 参数?或者 & 在 PHP 中?

我必须向url添加一个GET变量。但是URL可能已经有GET变量。添加这个新变量的最有效方法是什么?示例网址:http://domain.com/http://domain.com/index.html?name=jones我需要添加:tag=xyz:http://domain.com/?tag=xyzhttp://domain.com/index.html?name=jones&tag=xyz知道是否要在我的字符串前添加a的最有效方法是什么?还是&?这是我目前拥有的函数的一个版本://wherearrAdditionslookslikearray('key1'=>'value1','

php - __get() 和 __set() 是否意味着泄漏封装?

在OO编程中,使用魔法方法__get()和__set()会不会被人看不起,这些会导致类的封装泄漏吗?例如:classUser{private$username;private$password;publicfunction__set($name,$value){$this->$name=$value;}publicfunction__get($name){return$this->$name;}}这有效地使private/protected变量public。 最佳答案 您的代码:classUser{private$username;

php - file_get_contents 返回 PHP 代码

当我在本地文件上使用file_get_contents()函数时,结果包含php代码,尽管我只需要HTML。正在读取的文件内容:Hello';?>以及从位于同一文件夹中的不同文件调用file_get_contents的结果:"如果我从外部服务器读取文件,它会返回HTML-正如我所期望的那样。所以问题是:如何从本地文件中获取HTML输出?谢谢大家。 最佳答案 您可以使用文件url(不是文件路径),因此它由服务器处理,例如:echofile_get_contents('http://website.com/test.php');然而,i

PHP 使用 file_get_contents() 检查外部服务器上是否存在文件

使用file_get_contents()方法检查外部服务器上是否存在文件,此方法是否可以正常工作?$url_file="http://website.com/dir/filename.php";$contents=file_get_contents($url_file);if($contents){echo"FileExists!";}else{echo"FileDoesn'tExists!";} 最佳答案 我认为对我来说最好的方法是使用这个脚本:$file="http://website.com/dir/filename.php

PHP Curl Posting @Sign 返回 False

我得到了这个测试代码。文件名:test.php"@");$ch=curl_init();curl_setopt($ch,CURLOPT_URL,'http://localhost/post.php');curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);curl_setopt($ch,CURLOPT_POSTFIELDS,$array);curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"POST");$response=curl_exec($ch);curl_close($ch);var_dump($response);

php - query_posts() 应该避免吗?

我读到应该避免使用query_posts(),而使用wp_query()和pre_get_posts()。我对弄乱循环没有信心,也不完全理解法典。下面的代码是否使用了query_posts()?如果是,并且由于应避免使用query_posts(),您能否建议一种不使用query_posts()但仍能完成相同事情的方法?functions.php中的这段代码用于按随机或按价格对帖子进行排序。functionmy_custom_query($query){if($query->is_home()&&$query->is_main_query()){$sort=$_GET['sort'];i

php - symfony2 phpunit : how to get exception message when status code is not expected one

在我的symfony2应用程序中,我使用phpunit来测试每个Controller的Action响应的状态代码是否是预期的。如果不是,我如何让phpunit显示异常附带的错误消息,或者最好模拟一个探查器异常页面?这是因为我在phpunit中有一个返回500代码的操作,但它在我的浏览器中加载得很好。我的代码:/***@dataProviderurlProvider*@param$url*/publicfunctiontestPageIsSuccessful($url){$client=self::createClient(array(),array('PHP_AUTH_USER'=>'

php - file_get_contents() 没有响应 - php

我正在尝试调用一个基本如下所示的网络服务:http://10.10.10.10:8080/gw/someAction?amount=10&description='Somedescription'我就是这样称呼这个网络服务的:$endpoint="http://10.10.10.10:8080/gw/someAction?amount=10&description='Somedescription'";$opts=array('http'=>array('method'=>'GET','header'=>'Content-type:application/xml'));$context

php - 我正在努力做,_POST 是空的

我看了又看,但没有什么能完全触及这个问题。我正在尝试通过Chrome中的JavaScript*发送XMLHttpRequest。这是我的页面:ROAMfunctionpost_something(){varxmlhttp=newXMLHttpRequest();xmlhttp.open('POST',"post_test.php",true);xmlhttp.setRequestHeader('Content-Type','text/plain');xmlhttp.send("Thisismytext.");xmlhttp.onreadystatechange=function(){i

php - Aws PHP Sdk 3:S3::putObject():AWS HTTP 错误:cURL 错误 6:无法解析主机 's3.Ireland.amazonaws.com'

我尝试使用SDK版本3将图像上传到S3存储桶,但我收到以下错误:Errorexecuting"PutObject"on"https://s3.Ireland.amazonaws.com/my-bucket-name/testFile.jpg";AWSHTTPerror:cURLerror6:Couldn'tresolvehost's3.Ireland.amazonaws.com'(seehttp://curl.haxx.se/libcurl/c/libcurl-errors.html)这是我第一次尝试这样做,所以我没有太大的信心。通过AWS接口(interface)上传文件,其URL类