<?php class Request{ public static function post($url, $post_data = '', $timeout = 5){//curl $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_POST, 1); if($post_data != ''){ curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); } curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_HEADER, false); $file_contents = curl_exec($ch); curl_close($ch);
Post()函数用于向窗口发送非PowerBuilder预定义事件的消息,这个窗口可以是PowerBuilder应用的窗口,也可以是其它应用的窗口。Post()函数把发送的消息放置在指定窗口消息队列的尾部,然后返回到应用程序中,它并不等待相应事件事件处理程序的执行。这一点与Send()函数不同,Send()函数直接触发指定窗口相应的事件,执行事件处理程序后返回到调用应用中。因此,我们说Post()函数采用的是异步方式,Send()函数采用的是同步方式。Post()函数的参数handle指定接收消息的窗口句柄,对PowerBuilder窗口来说,使用Handle()函数可以得到该句柄。对其它应用程序的窗口来说,可以调用系统API函数查找窗口并得到相应窗口的句柄。如果应用程序要邮寄PowerBuilder定义事件(包括预定义事件和用户定义事件),那么使用PostEvent()函数既简单有方便。当应用程序在long参数位置指定一个字符串时,Post()函数复制一个该字符串的副本,然后将副本的地址传送给指定窗口。
本站所有资源均由网友贡献或各大下载网站转载。请自行检查软件的完整性!本站所有资源仅供学习参考。请不要将它们用于商业目的。否则,一切后果由您负责!如有侵权,请联系我们删除。联系方式:admin@php.cn
相关文章

29 Dec 2024
使用 file_get_contents() 发送 HTTP POST 请求 使用 PHP 的 file_get_contents() 从 URL 检索内容非常简单。然而,对于...

16 Nov 2024
使用 PHP 发送 JSON POST 请求在这种情况下,我们的目标是使用 PHP 通过 POST 请求将 JSON 数据发送到指定的 URL。问题...

27 Dec 2024
PHP cURL HTTP POST 示例在本文中,我们将演示如何使用 PHP cURL 发送 HTTP POST 请求。示例场景:我们想要发送...

30 Nov 2024
使用 PHP cURL 执行 RAW POST 请求在 PHP 中,使用 cURL 发送 RAW POST 请求需要指定特定选项来配置 cURL...

24 Dec 2024
PHP cURL 与 HTTP POST 简介 cURL 是 PHP 中用于通过网络传输数据的库。 cURL 的一个常见用例是发送...


Hot Tools
