TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   primitive url routing (http://www.talkphp.com/absolute-beginners/4551-primitive-url-routing.html)

fantomel 06-14-2009 06:40 PM

primitive url routing
 
hello i'm tryign to build a routing system and i'm playing a little to understand how it works but i`ve got a debugging problem can please someone help me?

PHP Code:

$url $_SERVER['REQUEST_URI'];
$array explode("/"$url);
$action 'index';
$dispatch = new $array[1];
if(
method_exists($dispatch$action))
{
    
call_user_func_array($dispatch$action);


My Error: Catchable fatal error: Object of class Blog could not be converted to string in C:\xampp\htdocs\public\index.php on line 11

Wildhoney 06-14-2009 07:45 PM

Which variable is assigned to the object (class) of Blog?

Enfernikus 06-14-2009 07:49 PM

You are using call_user_func_array incorrectly, when you want to call a method within an object it is used like so

php Code:
call_user_func_array(array($dispatch, $action), $args);

Where $args would be everything after the part of the url which proclaims the action

fantomel 06-14-2009 07:58 PM

thanks enfernikus your example worked perfect


All times are GMT. The time now is 04:33 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0