PHP implementation of the bulk test site can be opened to the normal method _php skills

Source: Internet
Author: User
Tags php programming php regular expression

This article describes the PHP implementation of the bulk test site can be opened in a normal way. Share to everyone for your reference, specific as follows:

curl_setopt function is an important function in PHP, it can imitate user's some behavior, such as imitate user login, register and so on some user can manipulate behavior.

<?php
//Set maximum execution time is 120 seconds
ini_set (' max_execution_time ',);
function Httpcode ($url) {
  $ch = Curl_init ();
  $timeout = 3;
  curl_setopt ($ch, curlopt_followlocation,1);
  curl_setopt ($ch, curlopt_returntransfer,1);
  curl_setopt ($ch, Curlopt_header, 1);
  curl_setopt ($ch, Curlopt_connecttimeout, $timeout);
  curl_setopt ($ch, Curlopt_url, $url);
  Curl_exec ($ch);
  return $httpcode = Curl_getinfo ($ch, curlinfo_http_code);
  Curl_close ($ch);
$check _web = Array (
' http://www.jb51.net/', '
http://sc.jb51.net/', '
http://tools.jb51.net/',
' http://baike.jb51.net/',
' http://demo.jb51.net/', '
http://demo2.jb51.net/',
);
For ($i =0 $i <count ($check _web), $i + +) {
  echo $check _web[$i]. '-> '. Httpcode ($check _web[$i]). ' <br> ';
}
? >

How to use:

If the display is 200, it is normal, if the other value indicates that it is not normal, and 3 after the $timeout sets the timeout number of seconds.

The effect chart is as follows:

More about PHP Interested readers can view the site topics: "Php Curl Usage Summary", "PHP array" operation Skills Daquan, "PHP Sorting algorithm Summary", "PHP common traversal algorithm and skills summary", "PHP Data structure and algorithm tutorial", " PHP Programming algorithm Summary, "PHP Mathematical Calculation Skills Summary", "PHP Regular Expression Usage summary", "PHP operation and operator Usage Summary", "PHP string (String) Usage summary" and "PHP common database Operation skill Summary"

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.