بروز خطا
[message]
اشتراک در سوال
رای ها
[dataList]
خطای Warning: call_user_func_array() expects parameter 2 to be array, string given
سلام من تو روتینگ درواقع بعد از تنظیم auto load به این مشکل برخوردم و وقتی پارامتری وارد url میکنم این خطا رو میده
Warning: call_user_func_array() expects parameter 2 to be array, string given
$controllerClassName = ucfirst($controller) . 'Controller';
$controllerInctance = new $controllerClassName();
if (!method_exists($controllerInctance, $method)) {
message('404', true);
}
call_user_func_array(array($controllerInctance, $method), $params);
0
0
چه یو ار الی وارد کردی؟؟ (9 سال پیش)
برای این سوال 2 پاسخ وجود دارد.
پاسخ به سوال
امین علیپور
9 سال پیش
+1
0
من یه کدی به همین روتینگ اضاف کردم که اگر ادرس وجود نداشت یه صفحه باز بشه و خیلی خوب کار میکنه .میزارمش تا دوستان استفاده کنن
کد فایل core.php
global $controller;
$amin =getcwd()."/mvc/controller/" . $controller . ".php";
if (file_exists($amin)) {
if (strhas($classname, "Controller")) {
$filename = str_replace("Controller", "", $classname);
$filename = strtolower($filename);
require_once(getcwd() . "/mvc/controller/$filename.php");
}
} else {
View::render('/test.php');
}
کد فایل index.php
if (count($parts > 1)) {
$controller = $parts[1];
if (count($parts) > 2) {
$method = $parts[2];
}
$params = array();
for ($i = 3; $i < count($parts); $i++) {
$params[] = $parts[$i];
}
}
global $controllerClassname;
$controllerClassname = ucfirst($controller) . "Controller";
if (class_exists($controllerClassname)) {
$controllerInstance = new $controllerClassname();
if (isset($controllerInstance) and isset($method)) {
if (method_exists($controllerInstance, $method)) {
call_user_func_array(array($controllerInstance, $method), $params);
} else {
View::render('/test.php');
}
} else {
View::render('/test.php');
}
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .