私はこの質問を自分で解決しました。ファイル名が間違っていました。PHPクラスが見つかりません
こんにちは皆さん!
私はDrupalとJoomlaのようなCMSを構築しています。私は、モジュールの機能(プラグイン)に取り組んでいる、と私は、次のエラーを得た:ここ
Fatal error: Class 'settings' not found in C:\wamp\www\SYSTEM\view.php on line 22
は私のコードです:
のsettings.phpstart.php
<?php
//First of all, start with some advertisement
header("X-Powered-By:ZOMFG CMS, and ofcourse PHP, but that's less important");
//Then less impotant stuff lololol.
session_start(); //Start a session
mysql_connect($db_host, $db_user, $db_pass); //Connect to database
mysql_select_db($db_name); //Select a database
//Load core
require_once("core.php");
//Load modules
$res_modules = mysql_query("SELECT * FROM ".$_SERVER["db_prefix"]."modules WHERE enabled=1");
echo mysql_error();
$module_exists = array();
while($row_modules = mysql_fetch_array($res_modules))
{
//Load module
$name = $row_modules["name"];
modules::load_module($name);
//and initialize it
eval($name."::init();");
//Yes, it exists
$module_exists[$name] = true;
}
//Check if the user wants shit from a module
if(isset($_GET["m"]))//Yes the user want it
{
//Does the module exist and activated, and has it a function called view?
if(isset($module_exists[$_GET["m"]]) && method_exists($_GET["m"], "view"))//Yep
{
//Load view (should be an array)
eval("\$module_view = ".$_GET["m"]."::view();");
if(!is_array($module_view))//Not an array :(
{
error::e500module($_GET["m"], $_SERVER["REQUEST_URI"]);
}
else//The error would kill the entire script, m'kay
{
view::index();
}
}
else//Nope, so display error
{
error::e404($_SERVER['REQUEST_URI']);
}
}
<?php
class settings
{
function get($what)
{
$result_get = mysql_query("SELECT value FROM ".$_SERVER["db_prefix"]."settings WHERE key='$what'");
if(mysql_num_rows($result_get) > 0)
{
$row_get = mysql_fetch_array($result_get);
return $result_get["value"];
}
else
{
return -1;
}
}
}
core.php
<?php
//Load core classes
require_once("settings.php");
require_once("error.php");
require_once("theme.php");
require_once("view.php");
require_once("modules.php");
view.php
<?php
class view
{
function head()
{
include("../THEMES/".settings::get("theme")."/head.php");
}
function foot()
{
include("../THEMES/".settings::get("theme")."/foot.php");
}
function left()
{
include("../THEMES/".settings::get("theme")."/left.php");
}
function right()
{
include("../THEMES/".settings::get("theme")."/right.php");
}
function index()
{
include("../THEMES/".settings::get("theme")."/index.php");
}
}
Start.phpは明らかに最初に実行されます。それ以前には他のページは実行されませんが、データベース情報を含むcustomsettings.phpは例外です。私は上記の私のコードで$ _SERVER [「db_prefixを」]を用いた場合、私はcustomsettings.phpに設定されているスーパーグローバルを必要とするので、それはです:
<?php
$db_host = "localhost"; //Database host
$db_user = "root"; //Database user
$db_pass = "you may not know this"; //Database password
$db_name = "zomfg"; //Database name
$_SERVER["db_prefix"] = "zomfg_";//Prefix, needs to be superglobal
customsettings.php誰も私を助けることができますか? settings.phpがインクルードされる前に、view.phpのindex関数が呼び出されたようです。申し訳ありませんが、この質問が大きければ、私はただ明確にしたいだけです。また、eval()が悪であると言っていない、私は知っている。
だから、設定クラスが見つからない理由を知りたいのですが。より多くのソースコードが必要な場合は、この質問にコメントしてください。
愚かなことがあるように、私はまた、命名の問題がありました。 .phpを忘れました。 – craigtadlock