List random fixed length integers and various server request methods
List random fixed length integers and various server request methods
- 1. Random integer generation function (number of digits: $ pw_length)
- Public function randk ($ pw_length)
- {
- $ Randpwd = '';
- For ($ I = 0; $ I <$ pw_length; $ I ++)
- {
- $ Randpwd. = chr (mt_rand (48, 57 ));
- }
- Return $ randpwd;
- }
- 2. Request listing methods
- Method 1.
- $ Url = "http://www.test.com/ssl ...";
- $ Opts = array (
- 'Http' => array (
- 'Timeout' => 25,
- 'Method' => "GET ",
- 'Header' => "Accept-language: en \ r \ n ".
- "Cookie: foo = bar \ r \ n ",
- )
- );
- $ Context = stream_context_create ($ opts );
- $ Xmlstr = file_get_contents ($ url, false, $ context );
- $ Xmlstr = trim ($ xmlstr );
- Method 2.
- Function cuel_get_contents ($ url, $ timeout = 1 ){
- $ CurlHandle = curl_init ();
- Curl_setopt ($ curlHandle, CURLOPT_URL, $ url );
- Curl_setopt ($ curlHandle, CURLOPT_RETURNTRANSFER, 1 );
- Curl_setopt ($ curlHandle, CURLOPT_TIMEOUT, $ timeout );
- $ Result = curl_exec ($ curlHandle );
- Curl_close ($ curlHandle );
- Return $ result;
- }
- $ Hx = cuel_get_contents ('http: // www.test.com ');
- Method 3.
- $ Url = "http://www.test.com/ssl ...";
- Echo" ";
-
|