鸿宇科技

鸿宇科技

这家伙有点懒,还没写个性签名!

  • 财富值15
  • 威望值0
  • 总积分25

个人信息

  • https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples
    <?php
    // These lines are mandatory.
    require_once 'Mobile_Detect.php';
    $detect = new Mobile_Detect;
    <?php
    // Basic detection.
    $detect->isMobile();
    $detect->isTablet();

    // Magic methods.
    $detect->isIphone();
    $detect->isSamsung();
    // [...]

    // Alternative to magic methods.
    $detect->is('iphone');

    // Find the version of component.
    $detect->version('Android');

    // Additional match method.
    $detect->match('regex.*here');

    // Browser grade method.
    $detect->mobileGrade();

    // Batch methods.
    $detect->setUserAgent($userAgent);
    $detect->setHttpHeaders($httpHeaders);
    <?php
    // Check for mobile environment.
    if ($detect->isMobile()) {

    // Your code here.
    

    }
    <?php
    // Check for tablet device.
    if($detect->isTablet()){

    // Your code here.
    

    }
    <?php
    // Check for any mobile device, excluding tablets.
    if ($detect->isMobile() && !$detect->isTablet()) {

    // Your code here.
    

    }
    <?php
    // Keep the value in $_SESSION for later use
    // and for optimizing the speed of the code.
    if(!$_SESSION['isMobile']){

    $_SESSION['isMobile'] = $detect->isMobile();
    

    }
    <?php
    // Redirect the user to your mobile version of the site.
    if($detect->isMobile()){

    header('http://m.yoursite.com', true, 301);
    

    }
    <?php
    // Include and instantiate the class.
    require_once 'Mobile_Detect.php';
    $detect = new Mobile_Detect;

    // Any mobile device (phones or tablets).
    if ( $detect->isMobile() ) {

    }

    // Any tablet device.
    if( $detect->isTablet() ){

    }

    // Exclude tablets.
    if( $detect->isMobile() && !$detect->isTablet() ){

    }

    // Check for a specific platform with the help of the magic methods:
    if( $detect->isiOS() ){

    }

    if( $detect->isAndroidOS() ){

    }

    // Alternative method is() for checking specific properties.
    // WARNING: this method is in BETA, some keyword properties will change in the future.
    $detect->is('Chrome')
    $detect->is('iOS')
    $detect->is('UCBrowser')
    $detect->is('Opera')
    // [...]

    // Batch mode using setUserAgent():
    $userAgents = array(
    'Mozilla/5.0 (Linux; Android 4.0.4; Desire HD Build/IMM76D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19',
    'BlackBerry7100i/4.1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/103',
    // [...]
    );
    foreach($userAgents as $userAgent){

    $detect->setUserAgent($userAgent);
    $isMobile = $detect->isMobile();
    $isTablet = $detect->isTablet();
    // Use the force however you want.

    }

    // Get the version() of components.
    // WARNING: this method is in BETA, some keyword properties will change in the future.
    $detect->version('iPad'); // 4.3 (float)
    $detect->version('iPhone') // 3.1 (float)
    $detect->version('Android'); // 2.1 (float)
    $detect->version('Opera Mini'); // 5.0 (float)
    // [...]

  • 收藏了教程
    一个很简单的无限级分类
  • 收藏了源码
    无限极分类数组的处理类
  • 收藏了教程
    无限级分类的简单实例
  • Yii::$app->user->setReturnUrl(Yii::$app->request->referrer); //只需要添加这句话就可以了

    public function actionLogin()
    {
        if (!Yii::$app->user->isGuest) {
            return $this->goHome();
        }
    
        $model = new LoginForm();
        if ($model->load(Yii::$app->request->post()) && $model->login()) {
            return $this->goBack();
        } else {
            Yii::$app->user->setReturnUrl(Yii::$app->request->referrer);    //只需要添加这句话就可以了
            return $this->render('login', [
                'model' => $model,
            ]);
        }
    }
    
  • 赞了回答

    在Yii2.0版本的advanced高级模板环境中:设置404自定义页面的方法!

    1、frontend->config->main.php添加如下:

    'errorHandler' => [
                'errorAction' => 'site/error',
            ],
    

    2、frontend->views->site->error.php中添加如下:(注:可以自行发挥制作更漂亮的404页面)

    <?php
    
    use yii\helpers\Html;
    
    $this->title = $name;
    
    $this->context->layout = false; //不使用布局
    
    ?>
    <div class="site-error">
    
        <h1><?= Html::encode($this->title) ?></h1>
    
        <div class="alert alert-danger">
            <?= nl2br(Html::encode($message)) ?>
        </div>
    
    </div>
    
  • 在Yii2.0版本的advanced高级模板环境中:设置404自定义页面的方法!

    1、frontend->config->main.php添加如下:

    'errorHandler' => [
                'errorAction' => 'site/error',
            ],
    

    2、frontend->views->site->error.php中添加如下:(注:可以自行发挥制作更漂亮的404页面)

    <?php
    
    use yii\helpers\Html;
    
    $this->title = $name;
    
    $this->context->layout = false; //不使用布局
    
    ?>
    <div class="site-error">
    
        <h1><?= Html::encode($this->title) ?></h1>
    
        <div class="alert alert-danger">
            <?= nl2br(Html::encode($message)) ?>
        </div>
    
    </div>
    
试用期 等级规则
25/50
资料完整度
50/100
用户活跃度
0/100

Ta的关注

0

Ta的粉丝

1

Ta的访客

0