0

hi this is new problem to me, I need to use an array for parameter or argument in a function

but php shows this error T_ELipsis which from what I read is a functions arguments

UPDATE : I should tell everyone, that I want to make a friendly/better url like www.example.try/eg/10

so I use .HTACCESS to redirect everything into index.php and get the REQUEST_URI and SCRIPT_NAME and remove the matching one from array.

then I turn $requestURI into array, and use one of the values for argument

so I think the problem is the arguments. here it is :

  $command = array_values($requestURI);

   switch($command[0])
{
case 'profile' :
    // We run the profile function from the profile.php file.
    profile($command[1]); // this is where the problem is, the argument
    break;
case 'myprofile' :
    // We run the myProfile function from the profile.php file.
    myProfile();
    break;
default:
    echo "404 Error : wrong page.";
    break;
}

//function profile
 function profile($chars)
{
   // We check if $chars is an Integer (ie. an ID) or a String (ie. a potential username)

if (is_int($chars)) {
    $id = $chars;
    echo"User ID adalah : ".$id;
} else {
    $username = mysqli_real_escape_string($chars);
    // Do the SQL to get the $user from his username
    // ...........
    echo"username adalah : ".$username;
}


}

note : function profile() is on another php file I already included it

Citra45Abadi
  • 207
  • 1
  • 6
  • 21

0 Answers0