php 助手功能

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 助手功能相关的知识,希望对你有一定的参考价值。

 <?php
 
 // Simple way of masking emails
 function mask_email($email ) {
        $char_shown = 2;

        $mail_parts = explode("@", $email);
        $username = $mail_parts[0];
        $len = strlen( $username );

        if( $len <= $char_shown ){
            return implode("@", $mail_parts );
        }

        //Logic: show asterisk in middle, but also show the last character before @
        $mail_parts[0] = substr( $username, 0 , $char_shown )
            . str_repeat("*", $len - $char_shown - 1 )
            . substr( $username, $len - $char_shown + 1 , 1  )
        ;

        return implode("@", $mail_parts );
    }


 function getRealUserIp()
    {
        switch(true){
            case (!empty($_SERVER['HTTP_X_REAL_IP'])) : return $_SERVER['HTTP_X_REAL_IP'];
            case (!empty($_SERVER['HTTP_CLIENT_IP'])) : return $_SERVER['HTTP_CLIENT_IP'];
            case (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) : return $_SERVER['HTTP_X_FORWARDED_FOR'];
            default : return $_SERVER['REMOTE_ADDR'];
        }
    }

以上是关于php 助手功能的主要内容,如果未能解决你的问题,请参考以下文章

php WooCommerce助手功能 - 作者:https://faish.al/2014/01/06/check-if-it-is-woocommerce-page/

php 数组助手类

PHP表单助手类[关闭]

php REST助手

php Laravel的Auth助手

php Adore Beauty获得json助手