Numeric functions, other rand, floor, ceil, round, $ REMOTE_ADDR numeric functions
Srand |
Random number initialization |
Rand |
Random number generation |
Floor |
Integer truncation |
Ceil |
Function rounded up to the nearest integer |
Round |
The function rounds a floating point number. |
Sqrt |
Square root |
Srand (random number initialization)
srand(time);
** Use the current time to initialize the random number generator.
Rand (random number)
[Example]
$ I = rand (0, 99); | _ upper limit | _ lower limit
** $ I is set to 0 ~ The random number of 99.
Floor (integer truncation)
[Example]
$i = floor(1.9);
** $ I is set to 1.
Ceil (function rounded up to the nearest integer)
[Example]
$i = ceil(1.1);
** $ I is set to 2.
Round (function rounding floating point number)
[Example]
$ I = round (1.5 [, 2]); | _ specifies the number of digits after the decimal point | _ value $ I = round (1.5 );
** $ I is set to 2.
$i = round(1.123, 2);
** $ I is set to 1.12.
Sqrt (square root)
[Example]
$i = sqrt(2);
** $ I is set to 1.14.
Other functions
Chmod |
Set permissions |
Sleep |
Delay seconds |
Chmod (set permissions)
[Example]
chmod("path/filename", 0666);
** Permission settings.
Sleep (delay in seconds)
[Example]
sleep(10);
** Stop PHP execution within 10 seconds. (Stop Execution at any time)
Environment variable
_ LINE __ |
Execution line number |
PHP_VERSION |
PHP version |
PHP_ OS |
PHP System |
|
|
$ DOCUMENT_ROOT |
Web root directory |
$ SCRIPT_FILENAME |
Current PHP physical Path Intelligence |
_ FILE __ |
Current PHP physical Path Intelligence |
|
|
$ REMOTE_ADDR |
IP address of the remote terminal |
$ HTTP_REFERER |
URL before the departure terminal |
$ HTTP_USER_AGENT |
Browser information |
$ SCRIPT_NAME |
Current PHP Path Intelligence |
$ PHP_SELF |
Current PHP Path Intelligence |
|
|
$ SERVER_NAME |
Server host name |
$ SERVER_SOFTWARE |
Software name and network version |
$ GATEWAY_INTERFACE |
CGI version of the Web server |
Image reflection
** Fopen ("php: // stdout", 'wb') does not work well if you try again.
Redirection
header("Location: path/filename"); |_ http://sak-main/test.htm ./w_test/test.php a001.php?p1=a
** Other HTML and PHP redirection methods.
Session Management
** PHP has session management that can be used in the same way as ASP session management. It is good to share and use variables between different pages.
Session_start (); |
Start marking |
Session_register ("ses1", "ses2 ″); |
Register session variables |
Action = "sestest2.php? " |
Session ID management |
** SID, PHP performs operations based on different environment configurations, even if not specified.
Session Test 1 Listen session test 1 quit
Session variable
$ Ses1 =
$ Ses2 =
Session Test 2 Listen session Test 2
Session variable
$ Ses1 =
$ Ses2 =