Php 致命错误:调用未定义的函数重定向()

Php 致命错误:调用未定义的函数重定向(),php,redirect,Php,Redirect,我正在使用将移动用户重定向到特定页面。但是,当我写这篇文章时,我得到了重定向的致命错误。谁能告诉我在哪里,我错过了什么 require_once 'Mobile_Detect.php'; $detect = new Mobile_Detect; $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer'); $scriptVersion = $detect-&

我正在使用将移动用户重定向到特定页面。但是,当我写这篇文章时,我得到了重定向的致命错误。谁能告诉我在哪里,我错过了什么

require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
$scriptVersion = $detect->getScriptVersion();

if ($detect->isMobile())
   redirect('iammobile.php');
else
   echo '<h1>I am Desktop</h1>';
尝试使用类似标题的样式


您应该使用header函数,而不是重定向:

<?php
    header("Location: iammobile.php");
?>
换成

  header('location:iammobile.php');

将此函数用作构造

public function __construct() {
    parent::__construct();
    $this->load->helper('form');
    $this->load->helper('url');
}
将此代码用作重定向

redirect(base_url().'login','refresh');

您需要添加$autoload['helper']=数组'url','form';在文件autoload.php中,在构造函数中添加构造函数,然后重定向函数将工作

函数构造{ 父项::_构造;
}

重定向不是一项功能。错误是相当清楚的。您在哪里创建此函数?你真的想要这个函数吗?请看这个问题中的很多选项:这意味着它在任何地方都找不到名为redirect的函数。尝试使用headerLocation:iammobile.php而不是teadhi,当我这样使用时:if$detect->isMobile headerLocation:iammobile.php;然后显示内部服务器错误您需要给出该文件的整个url..重定向时您的意思是:home/user/public\u html/?仍然不起作用。我用/home3/chew/public_html/fundmanagementsystem.com/demo/mobile/mobile.php和http://google.com Too检查您的服务器日志,看看为什么会显示内部服务器错误Hi,当我这样使用时:if$detect->isMobile headerLocation:iammobile.php;然后显示内部服务器错误。您是否在iammobile.php上检查此条件?如果是,它将在循环中重定向。
public function __construct() {
    parent::__construct();
    $this->load->helper('form');
    $this->load->helper('url');
}
redirect(base_url().'login','refresh');