php soap 调用获取返回信息
php教程 soap 调用获取返回信息
trace soap message
获取 soap返回信息
<?php
$ws = "http://www.111cn.net/sd/2001/temperatureservice.wsdl";
$zipcode = "23590";
$client = new soapclient($ws,array('trace' => 1));
$temperature = $client->gettemp($zipcode);
echo htmlspecialchars($client->__getlastrequest());
?>
得到函数原型从wsdl
<?php
$ws = "http://www.www.111cn.net/sd/2001/temperatureservice.wsdl";
$client = new soapclient($ws);
var_dump($client->__getfunctions());
?>
<?php
$ws = "http://www.xmethods.net/sd/2001/temperatureservice.wsdl";
$zipcode = "12312";
$client = new soapclient($ws,array('trace' => 1));
$temperature = $client->gettemp($zipcode);
echo htmlspecialchars($client->__getlastresponse());
?>
他们利用了递归的方法来实例目录遍历,可以查找出无限级目录的文件与文件夹中的文件并显示,下面是实例代码
<?php教程
$dir = 'f:game';
function read_dir_all($dir) {
$ret = array('dirs'=>array(), 'files'=>array());
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if($file != '.' && $file !== '..') {
$cur_path = $dir . directory_separator . $file;
if(is_dir($cur_path)) {
$ret['dirs'][$cur_path] = read_dir_all($cur_path);
} else {
$ret['files'][] = $cur_path;
}
}
}
closedir($handle);
}
return $ret;
}
$p = read_dir_all($dir);
echo '<pre>';
var_dump($p);
echo '</pre>';
?>
由于checkbox特殊性所以我们要获取它的值,在很我语言中都不一样的,在php教程 以我们是以数组形式来处理,并且利用遍历他的值,下面有大量实例。
<html>
<head>
<title>checkbox demo</title>
</head>
<body>
<h1>checkbox demo</h1><h3>demonstrates checkboxes</h3>
<form action ="handleformcheckbox.php"><ul>
<li><input type ="checkbox" name ="chkfries" value ="11.00">fries</li>
<li><input type ="checkbox" name ="chksoda" value ="12.85">soda</li>
<li><input type ="checkbox" name ="chkshake" value ="1.30">shake</li>
<li><input type ="checkbox" name ="chkketchup" value =".05">ketchup</li>
</ul>
<input type ="submit">
</form></body>
</html>
<!-- handleformcheckbox.php
<html>
<head>
<title>checkbox demo</title>
</head>
<body>
<h3>demonstrates reading checkboxes</h3>
<?
print <<<here
chkfries: $chkfries <br>
chksoda: $chksoda <br>
chkshake: $chkshake <br>
chkketchup: $chkketchup <br>
<hr>here;
$total = 0;
if (!empty($chkfries)){
print ("you chose fries <br>");
$total = $total + $chkfries;
}if (!empty($chksoda)){
print ("you chose soda <br>");
$total = $total + $chksoda;
}if (!empty($chkshake)){
print ("you chose shake <br>");
$total = $total + $chkshake;
}if (!empty($chkketchup)){
print ("you chose ketchup <br>");
$total = $total + $chkketchup;
}print "the total cost is $$total";
?>
</body>
</html>
-->
实例
<html>
<head>
<title>using default checkbox values</title>
</head>
<body>
<?php
$food = $_get[food];
$self = htmlentities($_server['php_self']);
if (!empty($food)) {
echo "the foods selected are:<br />";
foreach($food as $foodstuf)
{
echo "<strong>".htmlentities($foodstuf)."</strong><br />";
}
}
else
{
echo ("<form action="$self" ");
echo ('method="get">
<fieldset>
<label>italian <input type="checkbox" name="food[]" value="italian" />
</label>
<label>mexican <input type="checkbox" name="food[]" value="mexican" />
</label>
<label>chinese <input type="checkbox" name="food[]" value="chinese"
checked="checked" /></label>
</fieldset>
<input type="submit" value="go!" >');
}
?>
</body>
</html>
多选checkbox
<?php
$options = array('option 1', 'option 2', 'option 3');$valid = true;
if (is_array($_get['input'])) {
$valid = true;
foreach($_get['input'] as $input) {
if (!in_array($input, $options)) {
$valid = false;
}
}
if ($valid) {
//process input
}
}
?>
实例checkbox多值获取
<html>
<head>
<title>using default checkbox values</title>
</head>
<body>
<?php
$food = $_get["food"];//www.3ppt.com
if (!empty($food)){
echo "the foods selected are: <strong>";
foreach($food as $foodstuff){
echo '<br />'.htmlentities($foodstuff);
}
echo "</strong>.";
}
else {
echo ('
<form action="'. htmlentities($_server["php_self"]).'" method="get">
<fieldset>
<label>
italian
<input type="checkbox" name="food[]" value="italian" />
</label>
<label>
mexican
<input type="checkbox" name="food[]" value="mexican" />
</label>
<label>
chinese
<input type="checkbox" name="food[]" value="chinese" checked="checked" />
</label>
</fieldset>
<input type="submit" value="go!" />
</form> ');
}
?>
</body>
</html>
file_get_contents() 函数把整个文件读入一个字符串中。
和 file() 一样,不同的是 file_get_contents() 把文件读入一个字符串。
file_get_contents() 函数是用于将文件的内容读入到一个字符串中的首选方法。如果操作系统支持,还会使用内存映射技术来增强性能。
语法
file_get_contents(path,include_path,context,start,max_length)参数 描述
path 必需。规定要读取的文件。
include_path 可选。如果也想在 include_path 中搜寻文件的话,可以将该参数设为 "1"。
context 可选。规定文件句柄的环境。
context 是一套可以修改流的行为的选项。若使用 null,则忽略。
start 可选。规定在文件中开始读取的位置。该参数是 php教程 5.1 新加的。
max_length 可选。规定读取的字节数。该参数是 php 5.1 新加的。
php代码
<?php
function post($url, $post = null)
{
$context = array();
if (is_array($post))
{
ksort($post);
$context['http'] = array
(
'method' => 'post',
'content' => http_build_query($post, '', '&'),
);
}
return file_get_contents($url, false, stream_context_create($context));
}
$data = array
(
'name' => 'test',
'email' => 'test@gmail.com',
'submit' => 'submit',
);
echo post('http://localhost/5-5/request_post_result.php', $data);
?>
接收数据:request_post_result.php 接收经过post的数据:
php代码
<?php
echo $_post['name'];
echo $_post['email'];
echo $_post['submit'];
echo "fdfd";
?>
实例二
/**
* 其它版本
* 使用方法:
* $post_string = "app=request&version=beta";
* request_by_other('http://facebook.cn/restserver.php',$post_string);
*/
function request_by_other($remote_server,$post_string){
$context = array(
'http'=>array(
'method'=>'post',
'header'=>'content-type: application/x-www-form-urlencoded'."rn".
'user-agent : jimmy's post example beta'."rn".
'content-length: '.strlen($post_string)+8,
'content'=>'mypost='.$post_string)
);
$stream_context = stream_context_create($context);
$data = file_get_contents($remote_server,false,$stream_context);
return $data;
}
数组的排序
在php教程中,排序方式有三种,通过索引排序、通过值排序(不保留原索引)、通过值排序(保留原索引)。每种又分为升序、降序以及用户定义顺序三个函数。它们分别如下:
通过索引排序:①升序 ksort() ②降序 krsort() ③用户定义顺序 uksort()
不保留原索引值排序:①升序 sort() ②降序 rsort() ③用户定义顺序 usort()
保留原索引值排序:①升序 asort() ②降序 arsort() ③用户定义顺序 uasort()
在php中,也可以用array_multisort来一次排序多个数组,不过项目中可能用得比较少。
翻转数组,把数字索引翻转,索引重新从0开始:array_reverse()
把索引和值调换:array_flip()
随机顺序:shuffle()
迭代器遍历
$test01 = array('a', 'b', 'c');
// for
for ($i = 0; $i < count($test01); $i++) {
echo $test01[$i];
}
// foreach value only
foreach ($test01 as $value) {
echo $value;
}
// foreach key and value
$test01 = array('a' => 'aaaa', 'b' => 'bbbb', 'c' => 'cccc');
foreach ($test01 as $key => $value) {
echo "$key => $value";
}
$test01 = array('a' => 'aaaa', 'b' => 'bbbb', 'c' => 'cccc');
while (list($key, $value) = each($test01)) {
echo "$key => $value" . "<br/>";
}
php中,迭代遍历主要要用到以下函数。
current() 迭代的当前元素。
reset() 重新移动到第一个元素并返回它。
next() 移动到下一个元素并返回它。
prev() 移动到上一个元素并返回它。
end() 移动到最后一个元素并返回它。
each() 以数组的形式返回当前元素的索引和值,并移动到下一个迭代。
key() 返回当前的索引。
array_ walk() 为每一个元素调用函数。
array_ reduce() 为每一个元素依次计算。
变通遍历
array_walk($test01, walk_test);
function walk_test($key, $value) {
echo "walk: $key => $value" . "<br/>";
}
$test02 = array(1, 2, 3, 4, 5);
echo array_reduce($test02, reduce_test);
function reduce_test($run_result, $current_value) {
return $run_result + $current_value * $current_value;
}
相关文章
- 下面本文章来给大家介绍在php中成员变量的一些对比了,文章举了四个例子在这例子中分别对不同成员变量进行测试与获取操作,下面一起来看看。 有如下4个代码示例,你认...2016-11-25
- 这篇文章主要介绍了Spring AOP 对象内部方法间的嵌套调用方式,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2021-08-29
- php 获取用户IP与IE信息程序 function onlineip() { global $_SERVER; if(getenv('HTTP_CLIENT_IP')) { $onlineip = getenv('HTTP_CLIENT_IP');...2016-11-25
- php获取一个文件夹的mtime的程序了,这个就是时间问题了,对于这个问题我们来看小编整理的几个例子,具体的操作例子如下所示。 php很容易获取到一个文件夹的mtime,可以...2016-11-25
- 这篇文章主要介绍了mybatis-plus 返回部分字段的解决方式,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-10-02
- <?php require('path.inc.php'); header('content-Type: text/html; charset=utf-8'); $borough_id = intval($_GET['id']); if(!$borough_id){ echo ' ...2016-11-25
- 获取网站icon,常用最简单的方法就是通过website/favicon.ico来获取,不过由于很多网站都是在页面里面设置favicon,所以此方法很多情况都不可用。 更好的办法是通过google提供的服务来实现:http://www.google.com/s2/favi...2014-06-07
- 这篇文章主要介绍了c# 三种方法调用WebService接口的相关资料,文中示例代码非常详细,帮助大家更好的理解和学习,感兴趣的朋友可以了解下...2020-07-07
- 主要功能:获取浏览器显示区域(可视区域)的高度 : $(window).height(); 获取浏览器显示区域(可视区域)的宽度 :$(window).width(); 获取页面的文档高度 $(document).height(); 获取页面的文档宽度 :$(document).width();...2015-10-21
- jquery中jquery.offset().top / left用于获取div距离窗口的距离,jquery.position().top / left 用于获取距离父级div的距离(必须是绝对定位的div)。 (1)先介绍jquery.offset().top / left css: 复制代码 代码如下: *{ mar...2013-10-13
- 1、先讲讲JQuery的概念,JQuery首先是由一个 America 的叫什么 John Resig的人创建的,后来又很多的JS高手也加入了这个团队。其实 JQuery是一个JavaScript的类库,这个类库集合了很多功能方法,利用类库你可以用简单的一些代...2014-05-31
- 这篇文章主要介绍了js实现调用网络摄像头及常见错误处理,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-03-07
SQLMAP结合Meterpreter实现注入渗透返回shell
sqlmap 是一个自动SQL 射入工具。它是可胜任执行一个广泛的数据库管理系统后端指印, 检索遥远的DBMS 数据库等,下面我们来看一个学习例子。 自己搭建一个PHP+MYSQ...2016-11-25- 这篇文章介绍了c#动态调用Webservice的两种方法实例,有需要的朋友可以参考一下...2020-06-25
- 这篇文章主要介绍了C#获取字符串后几位数的方法,实例分析了C#操作字符串的技巧,具有一定参考借鉴价值,需要的朋友可以参考下...2020-06-25
- 这篇文章主要介绍了解决Vue watch里调用方法的坑,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-11-07
- 这篇文章主要给大家介绍了关于c#中的WebService及其调用方式的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-06-25
- 如果是为了取到tagName后再进行判断,那直接用下面的代码会更方便: $(element).is('input') 如果是要取到标签用作到别的地方,可以使用一下代码: $(element)[0].tagName 或: $(element).get(0).tagName...2014-05-31
- 复制代码 代码如下:$nodes = @$xpath->query("//*[@id='main_pr']/img/@src");$prurl = $nodes->item(0)->nodeValue;...2013-10-04
- 这篇文章主要介绍了解决vue watch数据的方法被调用了两次的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-11-07