Discussing PHP Frameworks: What, When, Why and Which? – Noupe Design Blog
How to use curl_multi() without blocking
How to use curl_multi() without blocking
A more efficient implementation of curl_multi()
curl_multi is a great way to process multiple HTTP requests in parallel in PHP. curl_multi is particularly handy when working with large data sets (like fetching thousands of RSS feeds at one time). Unfortunately there is very little documentation on the best way to implement curl_multi. As a result, most of the examples around the web are either inefficient or fail entirely when asked to handle more than a few hundred requests.
Test from HTC
This post is from HTC
PHPDoctor – 產生程式文件的好工具
【P】PHPDoctor – 產生程式文件的好工具 @ My Life :: 隨意窩 Xuite日誌
這是一套產生 PHP 程式文件的好東西~上次經由會議上,聽到小鳳介紹後,一直到了昨天才開始研究~
我就先到了 PHPDoctor 去下載程式。
然後放到可以執行 PHP 環境的Server上。
http://peej.github.com/phpdoctor/more.html
這裡有詳細的說明該 如何安裝設定及使用。
首先我將 phpdoctor 目錄裡的default.ini 複制一份來修改。
改的地方不多,應該說我看不懂的地方太多~哈~
附上我的設定檔 www.ini 的內容,
裡面我把我沒用到的都刪掉了~
PHP/CURL Examples Collection
libcurl – PHP Binding examples
PHP/CURL Examples Collection
PHP CURL 發送 GET 和 POST 語法
FQstory: PHP CURL 發送 GET 和 POST 語法
如果要連到連的網址的話
許多免費空間不支援FOPEN
大家可以使用CURL試試看PHP CURL
1、http的get傳送
$ch = curl_init(“/") ;
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ;
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ;
$output = curl_exec($ch) ;
$fh = fopen(“out.html", ‘w’) ;
fwrite($fh, $output) ;
fclose($fh) ;2、http的post傳送
EX1
$URL="www.mysite.com/test.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://$URL");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, “Data1=blah&Data2=blah");curl_exec ($ch);
curl_close ($ch);EX2
//extract data from the post
extract($_POST) ;
//set POST variables
$url = ‘/get-post.php’ ;
$fields = array(
‘lname’=>urlencode($last_name) ,
‘fname’=>urlencode($first_name) ,
‘title’=>urlencode($title) ,
‘company’=>urlencode($institution) ,
‘age’=>urlencode($age) ,
’email’=>urlencode($email) ,
‘phone’=>urlencode($phone)
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.’=’.$value.’&’ ; }
rtrim($fields_string ,’&’) ;
//open connection
$ch = curl_init() ;
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL,$url) ;
curl_setopt($ch, CURLOPT_POST,count($fields)) ;
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string) ;
//execute post
$result = curl_exec($ch) ;
//close connection
curl_close($ch) ;
PHP CURL 教學
PHP CURL 教學 | InspireGate 派克空間
最完整的CURL中文說明,學PHP的要好好掌握,有很多的參數,大部份都很有用,真正掌握了它和正則,一定就是個採集高手了。
Executing multiple curl requests in parallel with PHP and curl_multi_exec
Executing multiple curl requests in parallel with PHP and curl_multi_exec | Rusty Razor Blade
Let’s get one thing out in the open. Curl is sweet. It does it’s job very well, and I’m absoutely thrilled it exists.If you’re using curl in your PHP app to make web requests, you’ve probably realized that by doing them one after the other, the total time of your request is the sum of all the requests put together. That’s lame.
Unfortunately using the curl_multi_exec is poorly documented in the PHP manual.
Let’s say that your app is hitting APIs from these servers:
Google: .1s
Microsoft: .3s
rustyrazorblade.com: .5sYour total time will be .9s, just for api calls.
By using curl_multi_exec, you can execute those requests in parallel, and you’ll only be limited by the slowest request, which is about .5 sec to rustyrazorblade in this case, assuming your download bandwidth is not slowing you down.
Sample code:
$nodes = array(‘http://www.google.com’, ‘http://www.microsoft.com’, ‘http://www.rustyrazorblade.com’);
$node_count = count($nodes);$curl_arr = array();
$master = curl_multi_init();for($i = 0; $i < $node_count; $i++)
{
$url =$nodes[$i];
$curl_arr[$i] = curl_init($url);
curl_setopt($curl_arr[$i], CURLOPT_RETURNTRANSFER, true);
curl_multi_add_handle($master, $curl_arr[$i]);
}do {
curl_multi_exec($master,$running);
} while($running > 0);echo “results: “;
for($i = 0; $i < $node_count; $i++)
{
$results = curl_multi_getcontent ( $curl_arr[$i] );
echo( $i . “\n" . $results . “\n");
}
echo ‘done’;It’s really not documented on php.net how to use curl_multi_getcontent, so hopefully this helps someone.
OpenCV
OpenCV的自學手冊 @ 進哥的布拉格 :: 痞客邦 PIXNET ::
riday, April 11, 2008在念研究所時,跟實驗室彥廷學長一起合編了這份「OpenCV自學手冊」,裡面有圖文解說,幫助一些第一次想使用OpenCV的人加速上手速度,也很感謝強者彥廷學長[1]先起個頭來製作這份文件。
作者已不再維護此分文件,若對OpenCV有任何疑問請找其他討論區詢問,謝謝!
OpenCV自學手冊(OpenCV_DIY)下載點
Listing the most popular pages
Listing the most popular pages – MindTouch Community Portal
Listing the most popular pagesTable of contents
1. 1. Variation for 9.02 and later
1. 1.1. CodeThere is currently no built-in function for retrieving the most popular pages. However, there is an MindTouch API function which can be invoked from DekiScript!
For this sample, we use uri.build to build the URI from the site.api URi. Then, we use web.xml to fetch the document from it (see what the XML looks like). Now, we iterate over all elements in the document and print out foreach the link, title, and view count using xml.text.
DekiScript retrieves this information as the anonymous user (it does not pass on the context of the current user), so if your MindTouch is private, than this code snippet will return no pages.
view sourceprint?
12
- {{ web.link(uri.build(site.uri, “index.php", { title: xml.text(p, ‘path’) ?? “" }), xml.text(p, ‘title’)) }} ({{ num.format(xml.text(p, ‘metrics/metric.views’), ‘#,#00’) }} views)
3