Home  >  Article  >  Backend Development  >  How to determine whether a string is base64 encoded in PHP

How to determine whether a string is base64 encoded in PHP

小云云
小云云Original
2018-03-03 15:08:555497browse

This article mainly shares with you how to use PHP to determine whether a string is base64 encoded. I hope it can help you.

/**
 * 判断字符串是否base64编码
 */
function func_is_base64($str)
{  
    return $str == base64_encode(base64_decode($str)) ? true : false;  
}

Related recommendations:

How to use base64 encoding for html pictures instead

Javascript converts the absolute path of the picture to base64 encoding

php Secure URL string base64 encoding and decoding example code

The above is the detailed content of How to determine whether a string is base64 encoded in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn