Click here to Skip to main content
15,918,003 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Parse error: syntax error, unexpected '(' in C:\Program Files (x86)\Ampps\www\mvc2\index.php on line 17<pre>$ctlr->$url[1]();

<?php include "inc/header.php"; ?>


<?php
include 'system/libs/Main.php';
include 'system/libs/PController.php';

$url = $_GET['url'];
$url = rtrim($url, '/');
$url = explode('/', $url);


include 'app/controllers/'.$url[0].'.php';

$ctlr = new $url[0]();
$ctlr->$url[1]();




?>






<?php include "inc/footer.php"; ?>


What I have tried:

I try to dynamic access Controller & Method using array system.
Posted
Updated 30-Apr-19 5:58am

1 solution

First,
$ctlr->$url[1]();
is invalid php.

It should look like
$ctlr->url[1];
and then, it really doesn't do anything.

I'd imagine you copied this from somewhere and are quite clueless as to what it does, and more importantly, how you would do it.

$ctlr = new $url[0]();
doesn't do you any favors, either.

Meanwhile - your error is screaming to your face exactly what it thinks is wrong.

So - in answer to your question:   study php.

 
Share this answer
 
v2
Comments
Member 14349827 30-Apr-19 12:10pm    
problem solve have xampp version problem.

same code successfully run ampps not error

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900