无法重新展开show404()

时间:2016-04-30 13:11:43

标签: php function

Fatal error: Cannot redeclare show404() (previously declared in /Users/patrikbelis/www/todo/_inc/config.php:33) in /Users/patrikbelis/www/todo/_inc/config.php on line 36

这是我也尝试重命名等函数mine404pagetoshow()但仍然无法正常工作

我还在项目中搜索了函数,但在config,delete,edit.php

中只有3 ....

config.php中的代码

    <?php

ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);

// require stuff
require_once 'vendor/autoload.php';




// global variables
$base_url = 'http://localhost:8000/todo';


// connect to db
$database = new medoo([
    'database_type' => 'mysql',
    'database_name' => 'todoapp',
    'server'        => 'localhost',
    'username'      => 'root',
    'password'      => 'root',
    'charset'       => 'utf8',

]);

// global functions


function show404()
{
    header("HTTP/1.0 404 NOT FOUND");
    include_once "404.php";
    die();
}


 function get_item()
{


    // if we dont have id or its empty
    if ( ! isset($_GET['id']) || empty($_GET['id']) ) {
        return false;
    }

    global $database;

    $item = $database->get("items", "text", [
        "id" => $_GET['id']
    ]);

    if ( ! $item ) {
        return false;
    }

    return $item;

}

?>

这就是我如何将它加载到php文件 - delete.php中的代码,edit.php

<?php
    require_once '_inc/config.php';
    $item = get_item();
    if ( ! $item ) show404();
?>

404.php

<?php

include_once "partials/header.php"

?>

<div class="page-header">
    <h1><a href="/todo" style="color:black">404</a></h1>
</div>

<p>
    _not found
</p>

<?php include_once "partials/footer.php" ?>

尝试修复它一段时间,我也在这里和谷歌上阅读一些问题,但找不到解决方案

0 个答案:

没有答案