Str.php 711 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace laytp\library;
  3. /**
  4. * 字符串处理
  5. */
  6. class Str
  7. {
  8. /**
  9. * 下划线转驼峰
  10. * @param $str
  11. * @return string|string[]|null
  12. */
  13. public static function underlineToCamel($str)
  14. {
  15. $str = preg_replace_callback('/([-_]+([a-z]{1}))/i', function ($matches) {
  16. return strtoupper($matches[2]);
  17. }, $str);
  18. return $str;
  19. }
  20. // 生成密码
  21. public static function createPassword($password)
  22. {
  23. return password_hash(md5($password), PASSWORD_DEFAULT);
  24. }
  25. // 检验密码
  26. public static function checkPassword($password, $passwordHash)
  27. {
  28. return password_verify(md5($password), $passwordHash);
  29. }
  30. }