PHP function Tips (i)

Source: Internet
Author: User

Password encryption and authentication

password_hash- Creating a hash of the password (hash)

String Password_hash (String $password, Integer $algo [, array $options])
Currently supported algorithms ($ALGO parameters): 1. Password_default-Use the bcrypt algorithm (PHP 5.5.0 default). Note that this constant will change as PHP joins the newer, higher-intensity algorithm. Therefore, the length of the resulting result using this constant will change in the future. Therefore, the columns in the database that store the results can be more than 60 characters (preferably 255 characters). 2. Password_bcrypt-Creates a hash using the crypt_blowfish algorithm. This results in a compatible crypt () that uses "$2y$". The result will be a 60-character string, or FALSE on failure.

password_verify- Verify that the password matches the hash

Boolean password_verify (String $password, String $hash)

Example:

$password = "123456";//Gets the encrypted string $hash = Password_hash ($password, Password_default);//authentication Password $input = "123456"; if ( Password_verify ($input, $hash))    echo "password is correct"; else    echo "Password error";
get_headers

Gets all headers sent by the server in response to an HTTP request.

Array get_headers (string $url [, int $format = 0])

Parameters:

url - The destination URL.

format - If the optional parameter is format set to 1, get_headers () parses the corresponding information and sets the key name of the array.

Bccomp

Compare two arbitrary-precision numbers for high-precision floating-point comparison.

int Bccomp (String $left _operand, String $right _operand [, int $scale = int])

Parameters: The function of the $scale is to set the comparison to the decimal point.

return value:
If the number on the left of the two number left_operand compares to the number equal to the right right_operand returns 0,
The number on the left left_operand compares to the number on the right to right_operand return 1,
The number on the left left_operand compares the number of the right to the right_operand small return-1.

PHP function Tips (i)

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.